停车场管理系统的设计与实现_第1页
停车场管理系统的设计与实现_第2页
停车场管理系统的设计与实现_第3页
停车场管理系统的设计与实现_第4页
停车场管理系统的设计与实现_第5页
已阅读5页,还剩52页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

附录:一、停车场管理系统部分关键代码1、登录页面protectedvoidButton1_Click(objectsender,EventArgse){if(TextBox1.Text.Trim().Length==0){Response.AddHeader("Refresh","0");Label5.Text="此项为必填";}if(TextBox2.Text.Trim().Length==0){Response.AddHeader("Refresh","0");Label6.Text="此项为必填";}if(RadioButtonList1.SelectedValue.Trim().Length==0){Response.AddHeader("Refresh","0");Label7.Text="此项为必填";}DataClassesDataContextda=newDataClassesDataContext();vara=fromsinda.Loginwheres.UserName==TextBox1.Text.Trim()&&s.PassWord==TextBox2.Text.Trim()&&s.Class==RadioButtonList1.SelectedValue.ToString()selects;if(a.Count()==0){//Response.AddHeader("Refresh","0");Label8.Text="密码或用户名错误,请重新输入!";}else{//HttpCookiecookie=newHttpCookie("Login");//cookie.Values.Add("UseName",TextBox1.Text.Trim());//cookie.Values.Add("PassWord",TextBox2.Text.Trim());//cookie.Values.Add("Class",RadioButtonList1.SelectedValue.ToString());//cookie.Expires=DateTime.Now.AddDays(15);Session["UseName"]=TextBox1.Text.Trim();Session["PassWord"]=TextBox2.Text.Trim();Session["Class"]=RadioButtonList1.SelectedValue.ToString();Label8.Text="登录成功!";}}2、注册页面protectedvoidButton1_Click(objectsender,EventArgse){if(TextBox2.Text.Trim()==TextBox3.Text.Trim()){DataClassesDataContextda=newDataClassesDataContext();vara=fromsinda.Loginwheres.UserName==TextBox1.Text.ToString().Trim()selects;if(a.Count()!=0)Label6.Text="对不起,该用户名已经被使用!";else{Loginlg=newLogin();lg.UserName=TextBox1.Text.ToString().Trim();lg.PassWord=TextBox2.Text.ToString().Trim();lg.Class="会员用户";lg.Email=TextBox4.Text.ToString().Trim();da.Login.InsertOnSubmit(lg);da.SubmitChanges();Label6.Text="恭喜你,注册成功!";}}elseLabel6.Text="密码不一致,请重新输入!";}3、车位查询protectedvoidButton1_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}vara=fromsinda.ParkLotsInfowheres.IsEmpty==false&&s.IsEnable==trueselects;stringss="剩余空车位数量为:"+a.Count().ToString()+"\n";stringstr=string.Empty;foreach(varbina)str+=b.ID.ToString()+"";str=ss+"可用车位为:"+"\n"+str;TextBox2.Text=str;}protectedvoidButton2_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}vara=fromsinda.CarInfowheres.CarID==TextBox1.Text.Trim()selectnew{车牌号=s.CarID,进入时间=s.InTime,车位号=s.ParkLotsID};if(a.Count()==0)Label6.Text="对不起,没有该车信息!";else{GridView1.DataSource=a;GridView1.DataBind();}}protectedvoidButton3_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}vara=fromsinda.CarInfojoindinda.ParkLotsInfoons.ParkLotsIDequalsd.IDwhered.ID==Int32.Parse(DropDownList2.SelectedValue)selectnew{车位号=d.ID,进入时间=s.InTime,车牌号=s.CarID};GridView2.DataSource=a;GridView2.DataBind();}4、车位引导(1)、C#实现DIjkstra算法publicclassMarx{privateint[]distance;privateintrow;privateArrayListways=newArrayList();publicMarx(intn,paramsint[]d){this.row=n;distance=newint[row*row];for(inti=0;i<row*row;i++){this.distance[i]=d[i];}for(inti=0;i<this.row;i++)//有row个点,则从中心到各点的路有row-1条{ArrayListw=newArrayList();intj=0;w.Add(j);ways.Add(w);}}//publicArrayListFind_way(){ArrayListS=newArrayList(1);ArrayListSr=newArrayList(1);int[]Indexof_distance=newint[this.row];for(inti=0;i<row;i++){Indexof_distance[i]=i;}S.Add(Indexof_distance[0]);for(inti=0;i<this.row;i++){Sr.Add(Indexof_distance[i]);}Sr.RemoveAt(0);int[]D=newint[this.row];//存放中心点到每个点的距离//以上已经初始化了,S和Sr(里边放的都是点的编号)intCount=this.row-1;while(Count>0){//假定中心点的编号是0的贪吃法求路径for(inti=0;i<row;i++)D[i]=this.distance[i];intmin_num=(int)Sr[0];//距中心点的最小距离点编号foreach(intsinSr){if(D[s]<D[min_num])min_num=s;}//以上可以排序优化S.Add(min_num);Sr.Remove(min_num);//把最新包含进来的点也加到路径中((ArrayList)ways[min_num]).Add(min_num);//foreach(intelementinSr){intposition=element*(this.row)+min_num;boolexchange=false;//有交换标志if(D[element]<D[min_num]+this.distance[position])D[element]=D[element];else{D[element]=this.distance[position]+D[min_num];exchange=true;}//修改距离矩阵this.distance[element]=D[element];position=element*this.row;this.distance[position]=D[element];//修改路径if(exchange==true){((ArrayList)ways[element]).Clear();foreach(intpointin(ArrayList)ways[min_num])((ArrayList)ways[element]).Add(point);}}--Count;}returnways;}}protectedvoidselecChange(objectsender,EventArgse){}protectedvoidUnnamed1_Click(objectsender,EventArgse){intr=124;//列数int[]a=newint[r*r];intda=10000;for(inti=0;i<r;i++){for(intj=i+1;j<r;j++){a[i*r+j]=da;}}for(intk=81;k<120;k++){if(k%10!=0)a[k*r+k+1]=44;elsecontinue;}for(inti_1=1;i_1<21;i_1++)a[i_1*r+i_1+80]=65;for(inti_2=21;i_2<61;i_2++)a[i_2*r+i_2+60]=65;for(inti_3=61;i_3<81;i_3++)a[i_3*r+i_3+40]=65;a[121]=150;a[121*r+122]=310;a[122*r+123]=150;a[90*r+121]=80;a[91*r+121]=80;a[110*r+122]=80;a[111*r+122]=80;//完善距离矩阵(距离矩阵其实可以是个上三角矩阵,//但为了处理方便,还是将其完整成一个对称阵)for(inti=0;i<r;i++){for(intj=0;j<r;j++){if(i==j){a[i*r+j]=0;}a[j*r+i]=a[i*r+j];}}Marxm=newMarx(r,a);ArrayListline=m.Find_way();ArrayListpath=(ArrayList)line[Int32.Parse(DropDownList1.SelectedValue)];int[,]P=newint[124,2];P[0,0]=501;P[0,1]=7;P[121,0]=501;P[121,1]=160;P[122,0]=501;P[122,1]=470;P[123,0]=501;P[123,1]=624;for(intii=1;ii<121;ii++){switch(ii%20){case0:P[ii,0]=975;break;case1:P[ii,0]=26;break;case2:P[ii,0]=69;break;case3:P[ii,0]=112;break;case4:P[ii,0]=156;break;case5:P[ii,0]=199;break;case6:P[ii,0]=243;break;case7:P[ii,0]=286;break;case8:P[ii,0]=329;break;case9:P[ii,0]=373;break;case10:P[ii,0]=417;break;case11:P[ii,0]=582;break;case12:P[ii,0]=625;break;case13:P[ii,0]=669;break;case14:P[ii,0]=713;break;case15:P[ii,0]=758;break;case16:P[ii,0]=801;break;case17:P[ii,0]=843;break;case18:P[ii,0]=886;break;case19:P[ii,0]=932;break;}if(ii<21)P[ii,1]=95;if(ii>20&&ii<41)P[ii,1]=224;if(ii>40&&ii<61)P[ii,1]=404;if(ii>60&&ii<81)P[ii,1]=534;if(ii>80&&ii<101)P[ii,1]=160;if(ii>100&&ii<121)P[ii,1]=470;}Session["List"]=path;Session["pp"]=P;Session["Y"]="n";Panel2.BackImageUrl="WebPaintPic.aspx";}protectedvoidButton1_Click(objectsender,EventArgse){Response.AddHeader("Refresh","0");Session["Y"]="y";}(2)GDI画图protectedvoidPage_Load(objectsender,EventArgse){if(Session["Y"].ToString()=="n"){MemoryStreamstream=draw();Bitmapimg1=newBitmap(@"C:\Users\毛永波\Desktop\停车场平面图.bmp");img1.Save(stream,ImageFormat.Jpeg);//保存绘制的图片Response.Clear();Response.ContentType="image/jpeg";Response.BinaryWrite(stream.ToArray());}if(Session["Y"].ToString()=="y"){Response.AddHeader("Refresh","0");//MemoryStreamstream=refresh();//Bitmapimg1=newBitmap(@"C:\Users\毛永波\Desktop\停车场平面图.bmp");//img1.Save(stream,ImageFormat.Jpeg);//保存绘制的图片//Response.Clear();//Response.ContentType="image/jpeg";//Response.BinaryWrite(stream.ToArray());}}publicMemoryStreamrefresh(){Bitmapimg1=newBitmap(@"C:\Users\毛永波\Desktop\停车场平面图.bmp");MemoryStreamstream=newMemoryStream();//保存绘制的图片img1.Save(stream,ImageFormat.Jpeg);//保存绘制的图片returnstream;}publicMemoryStreamdraw(){Bitmapimg1=newBitmap(@"C:\Users\毛永波\Desktop\停车场平面图.bmp");Graphicsg=Graphics.FromImage(img1);//创建Graphics对象Penmypen=newPen(Color.Blue,3);ArrayListmpath=(ArrayList)Session["List"];int[,]PP=(int[,])Session["pp"];for(inti=0;i<mpath.Count-1;i++){Pointp1=newPoint{X=PP[(int)mpath[i],0],Y=PP[(int)mpath[i],1]};Pointp2=newPoint{X=PP[(int)mpath[i+1],0],Y=PP[(int)mpath[i+1],1]};g.DrawLine(mypen,p1,p2);}MemoryStreamstream=newMemoryStream();//保存绘制的图片img1.Save(stream,ImageFormat.Jpeg);//保存绘制的图片returnstream;}5、车位预定(1)、首页protectedvoidPage_Load(objectsender,EventArgse){HttpCookiecook1=Request.Cookies["Login"];if(cook1==null)Response.Redirect("../Accounts/Login.aspx");strings1="会员用户";if(Session["Class"]==null)Response.Redirect("../Accounts/Login.aspx");strings2=Session["Class"].ToString();if(Session["UseName"]==null&&Session["PassWord"]==null&&s2.Equals(s1))Response.Write("");elseResponse.Redirect("../Accounts/Login.aspx");DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}vara=fromsinda.ParkLotsInfowheres.IsEmpty==false&&s.IsEnable==trueselectnew{车位号=s.ID};GridView1.DataSource=a;GridView1.DataBind();}protectedvoidGridView1_PageIndexChanging1(objectsender,GridViewPageEventArgse){GridView1.PageIndex=e.NewPageIndex;GridView1.DataBind();}protectedvoidGridView1_SelectedIndexChanging(objectsender,GridViewSelectEventArgse){}protectedvoidLinkButton2_Click(objectsender,EventArgse){introw=((GridViewRow)((LinkButton)sender).NamingContainer).RowIndex;strings=GridView1.Rows[row].Cells[1].Text.ToString();Session["ParkNum"]=s;Response.Redirect("Book.aspx");}(2)、确认页protectedvoidPage_Load(objectsender,EventArgse){//HttpCookiecookie=Request.Cookies["Login"];Label2.Text=Session["UseName"].ToString();Label4.Text=Session["ParkNum"].ToString();}protectedvoidLinkButton1_Click(objectsender,EventArgse){}protectedvoidButton1_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}vara=fromsinda.Loginwheres.BookLotsNum==null&&s.UserName==Session["UseName"].ToString()selects;if(a.Count()==0)Label5.Text="您已经预定过车位,不能同时预定多个车位!";else{LoginL=a.Single();L.BookLotsNum=Convert.ToInt32(Session["ParkNum"]);da.SubmitChanges();varaa=fromsinda.ParkLotsInfowheres.ID==Convert.ToInt32(Session["ParkNum"])selects;ParkLotsInfop=aa.Single();p.IsEmpty=true;p.ArriveTime=DateTime.Now.AddHours(3);p.Predetermined="已预订";da.SubmitChanges();Label5.Text="车位预定成功,三个小时后自动取消";}}6、修改密码protectedvoidPage_Load(objectsender,EventArgse){HttpCookiecook1=Request.Cookies["Login"];if(cook1==null)Response.Redirect("../Accounts/Login.aspx");strings1="会员用户";if(Session["Class"]==null)Response.Redirect("../Accounts/Login.aspx");strings2=Session["Class"].ToString();if(Session["UseName"]==null&&Session["PassWord"]==null&&s2.Equals(s1))Response.Write("");elseResponse.Redirect("../Accounts/Login.aspx");}protectedvoidButton1_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();vara=fromsinda.Loginwheres.UserName==TextBox1.Text.Trim()&&s.PassWord==TextBox2.Text.Trim()&&s.Class=="会员用户"selects;if(a.Count()==0){Label6.Text="用户名或密码错误,请重新输入!";}else{if(TextBox3.Text.Trim()==null)Label6.Text="新密码不能为空!";else{if(TextBox3.Text.Trim()==TextBox4.Text.Trim()){Loginln=a.Single();ln.PassWord=TextBox3.Text.Trim();da.SubmitChanges();Label6.Text="修改密码成功!";}}}}7、车辆入管理protectedvoidPage_Load(objectsender,EventArgse){strings1="出入管理";if(Session["Class"]==null)Response.Redirect("../Accounts/Login.aspx");strings2=Session["Class"].ToString();if(Session["UseName"]==null&&Session["PassWord"]==null&&s2.Equals(s1))Response.Write("");elseResponse.Redirect("../Accounts/Login.aspx");}protectedvoidButton4_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}vara=fromsinda.Loginwheres.UserName==TextBox2.Text.Trim()&&s.PassWord==TextBox3.Text.Trim()&&s.Class=="会员用户"selects;if(a.Count()==0){Label7.Text="用户名或密码错误!";}else{if(a.Single().BookLotsNum==null)Label7.Text="未预定或预定已过期!";else{varb=fromsinda.ParkLotsInfowheres.ID==a.Single().BookLotsNumselects;ParkLotsInfopk=b.Single();pk.IsEmpty=true;pk.Predetermined=null;pk.ArriveTime=null;da.SubmitChanges();CarInfoc=newCarInfo();c.CarID=TextBox1.Text.Trim();c.InTime=DateTime.Now;c.ParkLotsID=Convert.ToInt32(a.Single().BookLotsNum);da.CarInfo.InsertOnSubmit(c);da.SubmitChanges();Loginlg=a.Single();lg.BookLotsNum=null;da.SubmitChanges();}}}protectedvoidButton1_Click(objectsender,EventArgse){DataClassesDataContextda=newDataClassesDataContext();varupdate=fromsinda.ParkLotsInfowheres.ArriveTime!=nullselects;if(update.Count()!=0){foreach(varoneinupdate){if(one.ArriveTime<=DateTime.Now){one.ArriveTime=null;one.IsEmpty=false;one.Predetermined=null;da.SubmitChanges();varupdatelog=fromsinda.Loginwheres.BookLotsNum==Convert.ToInt32(one.ID)selects;foreach(varhinupdatelog){h.BookLotsNum=null;da.SubmitChanges();}}}}varempty=fromsinda.ParkLotsInfowheres.IsEmpty==false&&s.IsEnable==trueselects;if(empty.Count()==0)Label8.Text="停车场已满!";else{ParkLotsInfopkf=empty.First();

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论