完整版的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#實現餐飲管理系統
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。