完整版的C#餐饮管理系统,供大家一起共同分享学习。
部分代码:
Dataoperator.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; /// <summary> ///Dataoperator 的摘要说明 /// </summary> public class Dataoperator { public Dataoperator() { // //TODO: 在此处添加构造函数逻辑 // } public static SqlConnection creatcon() { string strcon = ConfigurationManager.ConnectionStrings[ "ConnStr" ].ConnectionString; SqlConnection con = new SqlConnection(strcon); return con; } /// 查询的数据是否已经存在 /// </summary> /// <param name="sql">需要执行的SQL语句</param> /// <returns>返回布尔值,true表示已经存在,false表示不存在</returns> public static bool isData( string sql) { //创建数据库连接 SqlConnection con = creatcon(); //打开数据库连接 con.Open(); //创建Command对象 SqlCommand com = new SqlCommand(sql, con); //获取ExecuteScalar方法所返回的值 int ex = Convert.ToInt32(com.ExecuteScalar()); //关闭数据库连接 con.Close(); //判断整型变量并返回相应的布尔值 if (ex > 0) { return true ; } else { return false ; } } /// 执行数据库中的更新、插入、删除操作 /// </summary> /// <param name="sql">需要执行的SQL语句</param> /// <returns>返回布尔值,true表示已存在,false表示不存在</returns> public static bool exSql( string sql) { SqlConnection con = creatcon(); con.Open(); SqlCommand com = new SqlCommand(sql, con); int rows = Convert.ToInt32(com.ExecuteNonQuery()); if (rows > 0) return true ; else return false ; } public static string getTier( string sql) //返回指定列的值 { //SqlConnection con = creatcon() //con.Open(); //SqlCommand cmd = new SqlCommand(sql, con); ////获得记录行 //SqlDataReader sdr = cmd.ExecuteReader(); //sdr.Read(); //string str = sdr[0].ToString(); //con.Close(); //return str; SqlConnection con = creatcon(); SqlDataAdapter sda = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); sda.Fill(ds); string str = ds.Tables[0].Rows[0][0].ToString(); return str; } public static DataSet getRows( string sql) //返回所查询表中所有数据 { //创建数据库连接 SqlConnection con = creatcon(); //打开数据连接 //创建DataAdapter对象 SqlDataAdapter sda = new SqlDataAdapter(sql, con); //创建DataSet对象 DataSet ds = new DataSet(); //通过Fill方法 sda.Fill(ds); //关闭数据库连接 //返回DataSet对象 return ds; } } |
MessageBox.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; /// <summary> ///MessageBox 的摘要说明 /// </summary> public class MessageBox { public MessageBox() { // //TODO: 在此处添加构造函数逻辑 // } public static void Show( string messageInfo) { HttpContext.Current.Response.Write( "<script>alert('" +messageInfo+ "')</script>" ); } public static void Show( string messageInfo, string pagePath) { HttpContext.Current.Response.Write( "<script>alert('" +messageInfo+ "');location='" +pagePath+ "'</script>" ); } public static void ShowPath( string pagePath) { HttpContext.Current.Response.Write( "<script>location='" + pagePath + "'</script>" ); } } |
UserInformation.designer.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | #pragma warning disable 1591 //------------------------------------------------------------------------------ // <auto-generated> // 此代码由工具生成。 // 运行库版本:2.0.50727.1891 // // 对此文件的更改可能会导致不正确的行为,并且如果 // 重新生成代码,这些更改将会丢失。 // </auto-generated> //------------------------------------------------------------------------------ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Linq; using System.Linq.Expressions; using System.Reflection; [System.Data.Linq.Mapping.DatabaseAttribute(Name= "MenuLinq" )] public partial class UserInformationDataContext : System.Data.Linq.DataContext { private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); #region Extensibility Method Definitions partial void OnCreated(); partial void Insert用户信息(用户信息 instance); partial void Update用户信息(用户信息 instance); partial void Delete用户信息(用户信息 instance); partial void Insert订餐信息(订餐信息 instance); partial void Update订餐信息(订餐信息 instance); partial void Delete订餐信息(订餐信息 instance); partial void Insert菜样信息(菜样信息 instance); partial void Update菜样信息(菜样信息 instance); partial void Delete菜样信息(菜样信息 instance); #endregion public UserInformationDataContext() : base (global::System.Configuration.ConfigurationManager.ConnectionStrings[ "ConnStr" ].ConnectionString, mappingSource) { OnCreated(); } public UserInformationDataContext( string connection) : base (connection, mappingSource) { OnCreated(); } public UserInformationDataContext(System.Data.IDbConnection connection) : base (connection, mappingSource) { OnCreated(); } public UserInformationDataContext( string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : base (connection, mappingSource) { OnCreated(); } public UserInformationDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : base (connection, mappingSource) { OnCreated(); } public System.Data.Linq.Table<用户信息> 用户信息 { get { return this .GetTable<用户信息>(); } } public System.Data.Linq.Table<订餐信息> 订餐信息 { get { return this .GetTable<订餐信息>(); } } public System.Data.Linq.Table<菜样信息> 菜样信息 { get { return this .GetTable<菜样信息>(); } } } [Table(Name= "dbo.用户信息" )] public partial class 用户信息 : INotifyPropertyChanging, INotifyPropertyChanged { private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); private int _序号; private string _用户名; private string _用户密码; private string _邮箱; private string _住址; private string _手机号; #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); partial void OnCreated(); partial void On序号Changing( int value); partial void On序号Changed(); partial void On用户名Changing( string value); partial void On用户名Changed(); partial void On用户密码Changing( string value); partial void On用户密码Changed(); partial void On邮箱Changing( string value); partial void On邮箱Changed(); partial void On住址Changing( string value); partial void On住址Changed(); partial void On手机号Changing( string value); partial void On手机号Changed(); #endregion public 用户信息() { OnCreated(); } [Column(Storage= "_序号" , AutoSync=AutoSync.OnInsert, DbType= "Int NOT NULL IDENTITY" , IsPrimaryKey= true , IsDbGenerated= true )] public int 序号 { get { return this ._序号; } set { if (( this ._序号 != value)) { this .On序号Changing(value); this .SendPropertyChanging(); this ._序号 = value; this .SendPropertyChanged( "序号" ); this .On序号Changed(); } } } [Column(Storage= "_用户名" , DbType= "NChar(10)" )] public string 用户名 { get { return this ._用户名; } set { if (( this ._用户名 != value)) { this .On用户名Changing(value); this .SendPropertyChanging(); this ._用户名 = value; this .SendPropertyChanged( "用户名" ); this .On用户名Changed(); } } } [Column(Storage= "_用户密码" , DbType= "VarChar(50)" )] public string 用户密码 { get { return this ._用户密码; } set { if (( this ._用户密码 != value)) { this .On用户密码Changing(value); this .SendPropertyChanging(); this ._用户密码 = value; this .SendPropertyChanged( "用户密码" ); this .On用户密码Changed(); } } } [Column(Storage= "_邮箱" , DbType= "VarChar(50)" )] public string 邮箱 { get { return this ._邮箱; } set { if (( this ._邮箱 != value)) { this .On邮箱Changing(value); this .SendPropertyChanging(); this ._邮箱 = value; this .SendPropertyChanged( "邮箱" ); this .On邮箱Changed(); } } } [Column(Storage= "_住址" , DbType= "VarChar(50)" )] public string 住址 { get { return this ._住址; } set { if (( this ._住址 != value)) { this .On住址Changing(value); this .SendPropertyChanging(); this ._住址 = value; this .SendPropertyChanged( "住址" ); this .On住址Changed(); } } } [Column(Storage= "_手机号" , DbType= "VarChar(50)" )] public string 手机号 { get { return this ._手机号; } set { if (( this ._手机号 != value)) { this .On手机号Changing(value); this .SendPropertyChanging(); this ._手机号 = value; this .SendPropertyChanged( "手机号" ); this .On手机号Changed(); } } } public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; protected virtual void SendPropertyChanging() { if (( this .PropertyChanging != null )) { this .PropertyChanging( this , emptyChangingEventArgs); } } protected virtual void SendPropertyChanged(String propertyName) { if (( this .PropertyChanged != null )) { this .PropertyChanged( this , new PropertyChangedEventArgs(propertyName)); } } } [Table(Name= "dbo.订餐信息" )] public partial class 订餐信息 : INotifyPropertyChanging, INotifyPropertyChanged { private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); private int _序号; private System.Nullable< int > _菜样编号; private string _菜名; private string _菜样图片; private System.Nullable< int > _份数; private System.Nullable< int > _菜价; private System.Nullable< int > _应付金额; private string _订餐日期; private string _用户名; #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); partial void OnCreated(); partial void On序号Changing( int value); partial void On序号Changed(); partial void On菜样编号Changing(System.Nullable< int > value); partial void On菜样编号Changed(); partial void On菜名Changing( string value); partial void On菜名Changed(); partial void On菜样图片Changing( string value); partial void On菜样图片Changed(); partial void On份数Changing(System.Nullable< int > value); partial void On份数Changed(); partial void On菜价Changing(System.Nullable< int > value); partial void On菜价Changed(); partial void On应付金额Changing(System.Nullable< int > value); partial void On应付金额Changed(); partial void On订餐日期Changing( string value); partial void On订餐日期Changed(); partial void On用户名Changing( string value); partial void On用户名Changed(); #endregion public 订餐信息() { OnCreated(); } [Column(Storage= "_序号" , AutoSync=AutoSync.OnInsert, DbType= "Int NOT NULL IDENTITY" , IsPrimaryKey= true , IsDbGenerated= true )] public int 序号 { get { return this ._序号; } set { if (( this ._序号 != value)) { this .On序号Changing(value); this .SendPropertyChanging(); this ._序号 = value; this .SendPropertyChanged( "序号" ); this .On序号Changed(); } } } [Column(Storage= "_菜样编号" , DbType= "Int" )] public System.Nullable< int > 菜样编号 { get { return this ._菜样编号; } set { if (( this ._菜样编号 != value)) { this .On菜样编号Changing(value); this .SendPropertyChanging(); this ._菜样编号 = value; this .SendPropertyChanged( "菜样编号" ); this .On菜样编号Changed(); } } } [Column(Storage= "_菜名" , DbType= "NChar(10)" )] public string 菜名 { get { return this ._菜名; } set { if (( this ._菜名 != value)) { this .On菜名Changing(value); this .SendPropertyChanging(); this ._菜名 = value; this .SendPropertyChanged( "菜名" ); this .On菜名Changed(); } } } [Column(Storage= "_菜样图片" , DbType= "NChar(30)" )] public string 菜样图片 { get { return this ._菜样图片; } set { if (( this ._菜样图片 != value)) { this .On菜样图片Changing(value); this .SendPropertyChanging(); this ._菜样图片 = value; this .SendPropertyChanged( "菜样图片" ); this .On菜样图片Changed(); } } } [Column(Storage= "_份数" , DbType= "Int" )] public System.Nullable< int > 份数 { get { return this ._份数; } set { if (( this ._份数 != value)) { this .On份数Changing(value); this .SendPropertyChanging(); this ._份数 = value; this .SendPropertyChanged( "份数" ); this .On份数Changed(); } } } [Column(Storage= "_菜价" , DbType= "Int" )] public System.Nullable< int > 菜价 { get { return this ._菜价; } set { if (( this ._菜价 != value)) { this .On菜价Changing(value); this .SendPropertyChanging(); this ._菜价 = value; this .SendPropertyChanged( "菜价" ); this .On菜价Changed(); } } } [Column(Storage= "_应付金额" , DbType= "Int" )] public System.Nullable< int > 应付金额 { get { return this ._应付金额; } set { if (( this ._应付金额 != value)) { this .On应付金额Changing(value); this .SendPropertyChanging(); this ._应付金额 = value; this .SendPropertyChanged( "应付金额" ); this .On应付金额Changed(); } } } [Column(Storage= "_订餐日期" , DbType= "NVarChar(50)" )] public string 订餐日期 { get { return this ._订餐日期; } set { if (( this ._订餐日期 != value)) { this .On订餐日期Changing(value); this .SendPropertyChanging(); this ._订餐日期 = value; this .SendPropertyChanged( "订餐日期" ); this .On订餐日期Changed(); } } } [Column(Storage= "_用户名" , DbType= "NChar(15)" )] public string 用户名 { get { return this ._用户名; } set { if (( this ._用户名 != value)) { this .On用户名Changing(value); this .SendPropertyChanging(); this ._用户名 = value; this .SendPropertyChanged( "用户名" ); this .On用户名Changed(); } } } public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; protected virtual void SendPropertyChanging() { if (( this .PropertyChanging != null )) { this .PropertyChanging( this , emptyChangingEventArgs); } } protected virtual void SendPropertyChanged(String propertyName) { if (( this .PropertyChanged != null )) { this .PropertyChanged( this , new PropertyChangedEventArgs(propertyName)); } } } [Table(Name= "dbo.菜样信息" )] public partial class 菜样信息 : INotifyPropertyChanging, INotifyPropertyChanged { private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); private int _序号; private int _菜样编号; private string _菜名; private string _菜样类型; private string _菜样图片; private string _厨师; private System.Nullable< int > _现在价格; private System.Nullable< int > _优惠价格; private string _创菜时间; #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); partial void OnCreated(); partial void On序号Changing( int value); partial void On序号Changed(); partial void On菜样编号Changing( int value); partial void On菜样编号Changed(); partial void On菜名Changing( string value); partial void On菜名Changed(); partial void On菜样类型Changing( string value); partial void On菜样类型Changed(); partial void On菜样图片Changing( string value); partial void On菜样图片Changed(); partial void On厨师Changing( string value); partial void On厨师Changed(); partial void On现在价格Changing(System.Nullable< int > value); partial void On现在价格Changed(); partial void On优惠价格Changing(System.Nullable< int > value); partial void On优惠价格Changed(); partial void On创菜时间Changing( string value); partial void On创菜时间Changed(); #endregion public 菜样信息() { OnCreated(); } [Column(Storage= "_序号" , AutoSync=AutoSync.OnInsert, DbType= "Int NOT NULL IDENTITY" , IsPrimaryKey= true , IsDbGenerated= true )] public int 序号 { get { return this ._序号; } set { if (( this ._序号 != value)) { this .On序号Changing(value); this .SendPropertyChanging(); this ._序号 = value; this .SendPropertyChanged( "序号" ); this .On序号Changed(); } } } [Column(Storage= "_菜样编号" , DbType= "Int NOT NULL" )] public int 菜样编号 { get { return this ._菜样编号; } set { if (( this ._菜样编号 != value)) { this .On菜样编号Changing(value); this .SendPropertyChanging(); this ._菜样编号 = value; this .SendPropertyChanged( "菜样编号" ); this .On菜样编号Changed(); } } } [Column(Storage= "_菜名" , DbType= "NChar(10)" )] public string 菜名 { get { return this ._菜名; } set { if (( this ._菜名 != value)) { this .On菜名Changing(value); this .SendPropertyChanging(); this ._菜名 = value; this .SendPropertyChanged( "菜名" ); this .On菜名Changed(); } } } [Column(Storage= "_菜样类型" , DbType= "NChar(10)" )] public string 菜样类型 { get { return this ._菜样类型; } set { if (( this ._菜样类型 != value)) { this .On菜样类型Changing(value); this .SendPropertyChanging(); this ._菜样类型 = value; this .SendPropertyChanged( "菜样类型" ); this .On菜样类型Changed(); } } } [Column(Storage= "_菜样图片" , DbType= "NVarChar(50)" )] public string 菜样图片 { get { return this ._菜样图片; } set { if (( this ._菜样图片 != value)) { this .On菜样图片Changing(value); this .SendPropertyChanging(); this ._菜样图片 = value; this .SendPropertyChanged( "菜样图片" ); this .On菜样图片Changed(); } } } [Column(Storage= "_厨师" , DbType= "NChar(15)" )] public string 厨师 { get { return this ._厨师; } set { if (( this ._厨师 != value)) { this .On厨师Changing(value); this .SendPropertyChanging(); this ._厨师 = value; this .SendPropertyChanged( "厨师" ); this .On厨师Changed(); } } } [Column(Storage= "_现在价格" , DbType= "Int" )] public System.Nullable< int > 现在价格 { get { return this ._现在价格; } set { if (( this ._现在价格 != value)) { this .On现在价格Changing(value); this .SendPropertyChanging(); this ._现在价格 = value; this .SendPropertyChanged( "现在价格" ); this .On现在价格Changed(); } } } [Column(Storage= "_优惠价格" , DbType= "Int" )] public System.Nullable< int > 优惠价格 { get { return this ._优惠价格; } set { if (( this ._优惠价格 != value)) { this .On优惠价格Changing(value); this .SendPropertyChanging(); this ._优惠价格 = value; this .SendPropertyChanged( "优惠价格" ); this .On优惠价格Changed(); } } } [Column(Storage= "_创菜时间" , DbType= "NChar(20)" )] public string 创菜时间 { get { return this ._创菜时间; } set { if (( this ._创菜时间 != value)) { this .On创菜时间Changing(value); this .SendPropertyChanging(); this ._创菜时间 = value; this .SendPropertyChanged( "创菜时间" ); this .On创菜时间Changed(); } } } public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; protected virtual void SendPropertyChanging() { if (( this .PropertyChanging != null )) { this .PropertyChanging( this , emptyChangingEventArgs); } } protected virtual void SendPropertyChanged(String propertyName) { if (( this .PropertyChanged != null )) { this .PropertyChanged( this , new PropertyChangedEventArgs(propertyName)); } } } #pragma warning restore 1591 |
源码下载:C#实现餐饮管理系统
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。