⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmcaidanadd.cs

📁 一个酒店管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace bggl.fm
{
	/// <summary>
	/// frmcaidanadd 的摘要说明。
	/// </summary>
	public class frmcaidanadd : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox textBox4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.TextBox textBox5;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button4;

		int j;
		DataGrid z;
		ComboBox c;
		cs.frmcaidanadd ii=new bggl.cs.frmcaidanadd ();
		private System.Windows.Forms.GroupBox groupBox2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmcaidanadd(int local,DataGrid dg,ComboBox cb)
		{
			j=local;
			z=dg;
			c=cb;
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.textBox4 = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.textBox5 = new System.Windows.Forms.TextBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.button4 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(80, 24);
			this.label1.TabIndex = 0;
			this.label1.Text = "菜单编号:";
			// 
			// textBox1
			// 
			this.textBox1.Enabled = false;
			this.textBox1.Location = new System.Drawing.Point(104, 24);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(112, 21);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.Location = new System.Drawing.Point(24, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 24);
			this.label2.TabIndex = 2;
			this.label2.Text = "菜型:";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(104, 56);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(112, 21);
			this.textBox2.TabIndex = 3;
			this.textBox2.Text = "";
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label3.Location = new System.Drawing.Point(24, 96);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(64, 24);
			this.label3.TabIndex = 4;
			this.label3.Text = "菜名:";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(104, 96);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(112, 21);
			this.textBox3.TabIndex = 5;
			this.textBox3.Text = "";
			// 
			// label4
			// 
			this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label4.Location = new System.Drawing.Point(8, 128);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(80, 24);
			this.label4.TabIndex = 6;
			this.label4.Text = "菜名编号:";
			// 
			// textBox4
			// 
			this.textBox4.Location = new System.Drawing.Point(104, 128);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(112, 21);
			this.textBox4.TabIndex = 7;
			this.textBox4.Text = "";
			this.textBox4.Leave += new System.EventHandler(this.textBox4_Leave);
			// 
			// label5
			// 
			this.label5.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label5.Location = new System.Drawing.Point(24, 168);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(48, 16);
			this.label5.TabIndex = 8;
			this.label5.Text = "单价:";
			// 
			// textBox5
			// 
			this.textBox5.Location = new System.Drawing.Point(104, 160);
			this.textBox5.Name = "textBox5";
			this.textBox5.Size = new System.Drawing.Size(112, 21);
			this.textBox5.TabIndex = 9;
			this.textBox5.Text = "";
			this.textBox5.Leave += new System.EventHandler(this.textBox5_Leave);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.button4);
			this.groupBox1.Controls.Add(this.button3);
			this.groupBox1.Controls.Add(this.button2);
			this.groupBox1.Location = new System.Drawing.Point(288, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(112, 200);
			this.groupBox1.TabIndex = 10;
			this.groupBox1.TabStop = false;
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(16, 120);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(80, 24);
			this.button4.TabIndex = 3;
			this.button4.Text = "退出";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(16, 80);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(80, 24);
			this.button3.TabIndex = 2;
			this.button3.Text = "删除";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(16, 40);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(80, 24);
			this.button2.TabIndex = 1;
			this.button2.Text = "修改";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.textBox1);
			this.groupBox2.Controls.Add(this.label1);
			this.groupBox2.Controls.Add(this.label2);
			this.groupBox2.Controls.Add(this.textBox2);
			this.groupBox2.Controls.Add(this.label3);
			this.groupBox2.Controls.Add(this.textBox3);
			this.groupBox2.Controls.Add(this.label4);
			this.groupBox2.Controls.Add(this.textBox4);
			this.groupBox2.Controls.Add(this.label5);
			this.groupBox2.Controls.Add(this.textBox5);
			this.groupBox2.Location = new System.Drawing.Point(16, 8);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(264, 200);
			this.groupBox2.TabIndex = 11;
			this.groupBox2.TabStop = false;
			// 
			// frmcaidanadd
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(408, 229);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Name = "frmcaidanadd";
			this.Text = "菜单管理";
			this.Load += new System.EventHandler(this.frmcaidanadd_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmcaidanadd_Load(object sender, System.EventArgs e)    //从frmcaidan的数据框中取值
		{
			
			DataSet objset=ii.selectcaidan(j);
			foreach(DataRow dr in objset.Tables[0].Rows)
			{
				this.textBox1.Text=dr["mid"].ToString();
				this.textBox2.Text=dr["mtype"].ToString();
				this.textBox3.Text=dr["mname"].ToString();
				this.textBox4.Text=dr["mcpuid"].ToString();
				this.textBox5.Text=dr["mprice"].ToString();
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			this.textBox1.Text="";
			this.textBox2.Text="";
			this.textBox3.Text="";
			this.textBox4.Text="";
			this.textBox5.Text="";
			this.button2.Enabled=false;
			this.button3.Enabled=false;
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
			if(this.textBox2.Text.Trim()!="" && this.textBox3.Text.Trim()!="" && this.textBox4.Text.Trim()!="" && this.textBox5.Text.Trim()!="")
			{
//				if(this.textBox5.Text.GetType(int))
//				{
					ii.addcaidan(this.textBox2.Text,this.textBox3.Text,this.textBox4.Text,this.textBox5.Text);
					cs.selectmenu fork=new bggl.cs.selectmenu();
					DataSet objset=fork.selmenu("","");


					z.DataSource=objset.Tables[0].DefaultView;
					setlv();
					MessageBox.Show("保存成功!");
//				}
//				else
//				{
//					MessageBox.Show("单价不能输入字符类型,只能是money类型!"); 
//				}
			}
			else
			{
                  MessageBox.Show("操作不正确,输入不能为空,保存失败!");			
			}
          
			
		   
			this.button2.Enabled=true;
			this.button3.Enabled=true;
		}
		private void setlv()    //餐厅类型
		{
			DataSet sbobjset=new DataSet();
			cs.selectmenu sbsql=new bggl.cs.selectmenu();
			sbobjset=sbsql.seltype();
			this.c.Items.Clear();
			foreach(DataRow dr in sbobjset.Tables[0].Rows)
			{
				this.c.Items.Add(dr["mtype"].ToString());
				this.c.SelectedIndex=0;
			}
			
		}


		private void button4_Click(object sender, System.EventArgs e)   //退出
		{
			this.Close();
		}

		private void button2_Click(object sender, System.EventArgs e)   //修改菜单
		{
		   ii.updatecaidan(Convert.ToInt16(this.textBox1.Text),this.textBox2.Text,this.textBox3.Text,this.textBox4.Text,this.textBox5.Text);
			cs.selectmenu fork=new bggl.cs.selectmenu();
			DataSet objset=fork.selmenu("","");
			z.DataSource=objset.Tables[0].DefaultView;
			setlv();
			MessageBox.Show("已修改成功!");
		}

		private void button3_Click(object sender, System.EventArgs e)   //删除菜单
		{
			ii.deletecaidan(Convert.ToInt16(this.textBox1.Text));
			cs.selectmenu fork=new bggl.cs.selectmenu();
			DataSet objset=fork.selmenu("","");
			z.DataSource=objset.Tables[0].DefaultView;
			setlv();
			MessageBox.Show("已删除成功!"); 
		}

		private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void textBox5_Leave(object sender, System.EventArgs e)    //判断textBox5
		{
		    bggl.gong.zhipd pd=new bggl.gong.zhipd();
			if(pd.zhi(this.textBox5.Text.Trim())!=true)
			{
				MessageBox.Show("价格只能输入数字!");
				this.textBox5.Text="";
			}
		}

		private void textBox4_Leave(object sender, System.EventArgs e)    //判断textBox4
		{
			bggl.gong.zhipd pd=new bggl.gong.zhipd();
			if(pd.intjc(this.textBox4.Text.Trim())!=true)
			{
				MessageBox.Show("菜单编号只能为数字!");
				this.textBox4.Text="";
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -