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

📄 frmedithotel.cs

📁 酒店管理,主要从事酒店管理都可以.这可是北大青鸟的程序
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.txtHotelLevel.Size = new System.Drawing.Size(191, 21);
			this.txtHotelLevel.TabIndex = 35;
			this.txtHotelLevel.Text = "";
			// 
			// txtHotelPlace
			// 
			this.txtHotelPlace.Location = new System.Drawing.Point(102, 108);
			this.txtHotelPlace.Name = "txtHotelPlace";
			this.txtHotelPlace.Size = new System.Drawing.Size(191, 21);
			this.txtHotelPlace.TabIndex = 34;
			this.txtHotelPlace.Text = "";
			// 
			// txtHotelAddr
			// 
			this.txtHotelAddr.Location = new System.Drawing.Point(102, 147);
			this.txtHotelAddr.Name = "txtHotelAddr";
			this.txtHotelAddr.Size = new System.Drawing.Size(192, 21);
			this.txtHotelAddr.TabIndex = 33;
			this.txtHotelAddr.Text = "";
			// 
			// txtHotelName
			// 
			this.txtHotelName.Location = new System.Drawing.Point(102, 36);
			this.txtHotelName.Name = "txtHotelName";
			this.txtHotelName.Size = new System.Drawing.Size(192, 21);
			this.txtHotelName.TabIndex = 32;
			this.txtHotelName.Text = "";
			// 
			// LabelImage
			// 
			this.LabelImage.Location = new System.Drawing.Point(330, 150);
			this.LabelImage.Name = "LabelImage";
			this.LabelImage.Size = new System.Drawing.Size(67, 11);
			this.LabelImage.TabIndex = 31;
			this.LabelImage.Text = "酒店图片:";
			// 
			// LabelHotelDes
			// 
			this.LabelHotelDes.Location = new System.Drawing.Point(30, 186);
			this.LabelHotelDes.Name = "LabelHotelDes";
			this.LabelHotelDes.Size = new System.Drawing.Size(67, 11);
			this.LabelHotelDes.TabIndex = 30;
			this.LabelHotelDes.Text = "酒店描述:";
			// 
			// LabelHotelLevel
			// 
			this.LabelHotelLevel.Location = new System.Drawing.Point(30, 75);
			this.LabelHotelLevel.Name = "LabelHotelLevel";
			this.LabelHotelLevel.Size = new System.Drawing.Size(67, 11);
			this.LabelHotelLevel.TabIndex = 29;
			this.LabelHotelLevel.Text = "酒店星级:";
			// 
			// LabelHotelPlace
			// 
			this.LabelHotelPlace.Location = new System.Drawing.Point(30, 114);
			this.LabelHotelPlace.Name = "LabelHotelPlace";
			this.LabelHotelPlace.Size = new System.Drawing.Size(67, 11);
			this.LabelHotelPlace.TabIndex = 28;
			this.LabelHotelPlace.Text = "酒店位置:";
			// 
			// LabelHotelAddr
			// 
			this.LabelHotelAddr.Location = new System.Drawing.Point(30, 150);
			this.LabelHotelAddr.Name = "LabelHotelAddr";
			this.LabelHotelAddr.Size = new System.Drawing.Size(67, 11);
			this.LabelHotelAddr.TabIndex = 27;
			this.LabelHotelAddr.Text = "酒店地址:";
			// 
			// LabelHotelName
			// 
			this.LabelHotelName.Location = new System.Drawing.Point(30, 39);
			this.LabelHotelName.Name = "LabelHotelName";
			this.LabelHotelName.Size = new System.Drawing.Size(67, 11);
			this.LabelHotelName.TabIndex = 26;
			this.LabelHotelName.Text = "酒店名称:";
			// 
			// frmEditHotel
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(619, 384);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.btnChange);
			this.Controls.Add(this.btnSave);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmEditHotel";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "酒店信息管理";
			this.Load += new System.EventHandler(this.frmEditHotel_Load);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmEditHotel_Load(object sender, System.EventArgs e)
		{	
			//MessageBox.Show(this.temp);
			dbcon2 = new DBService_2();

			string sqlstr = "select hotelName,HotelAddr,HotelPlace,HotelLevel,description,image,Password from hotel where User = '" + GlobalVars.temp + " '";
			dsEdit = dbcon2.executeBySQL(sqlstr);
			row = dsEdit.Tables[0].Rows[0];
			txtHotelName.Text = (string)row["hotelName"];
			txtHotelLevel.Text = row["HotelLevel"].ToString();
			txtHotelPlace.Text = (string)row["HotelPlace"];
			txtHotelAddr.Text = (string)row["HotelAddr"];
			txtHotelDes.Text = (string)row["description"];
			txtOldPwd.Text = (string)row["Password"];
			
			//将图片从mysql数据库中取出并存入picturebox控件
			if(row["image"]!=DBNull.Value)
			{
				MemoryStream ms=new MemoryStream((byte[])row["image"]);
				picboxHotel.Image = new Bitmap(ms);
				ms.Close();
			}

		}

		private void btnChange_Click(object sender, System.EventArgs e)
		{
			// 打开文件对话框,选中图片文件

			openFD.Title = "选择图片";  //设置对话框标题
			openFD.InitialDirectory = "d:\\";  //设置默认打开路径
			openFD.Filter = "图片文件 (*.jpg,*.bmp,*.gif)|*.jpg;*.bmp;*.gif|所有文件 (*.*)|*.*";  // 文件过滤类型
			//openFD.FilterIndex = 1;  //缺省过滤类型索引
		
			if(openFD.ShowDialog() == DialogResult.OK) 
			{ 
				picboxHotel.Image = Image.FromFile(openFD.FileName);  //从指定的文件创建Image对象并传给picturebox
			}  
		}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			string strUpdate="";
			if(txtHotelName.Text == "")
			{
				MessageBox.Show(this,"请输入酒店名称!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
				txtHotelName.Focus();
				return;
			}
			if(txtHotelLevel.Text == "")
			{
				MessageBox.Show(this,"请输入酒店星级!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
				txtHotelLevel.Focus();
				return;
			}
			if(txtHotelPlace.Text == "")
			{
				MessageBox.Show(this,"请输入酒店位置!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
				txtHotelPlace.Focus();
				return;
			}
			if(txtHotelAddr.Text == "")
			{
				MessageBox.Show(this,"请输入酒店地址!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
				txtHotelAddr.Focus();
				return;
			}
//			if(txtHotelDes.Text == "")
//			{
//				MessageBox.Show(this,"请输入酒店描述!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
//				txtHotelDes.Focus();
//				return;
//			}

			if(txtNewPwd.Text != "")
			{
				if(!txtNewPwd.Text.Trim().Equals(txtReNew.Text.Trim()))
				{
					MessageBox.Show(this,"新密码与旧密码不一致,请重新输入!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
					return;
				}
				strUpdate=" password='"+txtNewPwd.Text.Trim()+"',";
			}
			//Stream st=this.openFD.OpenFile();
			//int len=(int)st.Length;
			//byte[] b = new byte[len-1];
			//st.Read(b,0,len-1);

			//把picturebox里的图片保存到数据库
			MemoryStream ms = new MemoryStream(1024*1024*10);
			picboxHotel.Image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
			int len=(int)ms.Position;
			byte[] b = new byte[len];
			ms.Seek(0,System.IO.SeekOrigin.Begin);
			ms.Read(b,0,len);
			ms.Close();

			string sqlstring = "update hotel SET hotelName = '"+ txtHotelName.Text.Trim() +" ',";
			sqlstring += " HotelLevel = '"+ txtHotelLevel.Text.Trim() +" ',";
			sqlstring += " HotelPlace = '"+ txtHotelPlace.Text.Trim() +" ',";
			sqlstring += " HotelAddr = '"+ txtHotelAddr.Text.Trim() +" ',";
			sqlstring += " description = '"+ txtHotelDes.Text.Trim() +" ',";
			sqlstring += strUpdate;
			sqlstring += " image = ?";
			sqlstring += " where User = '"+ GlobalVars.temp +"'";	


			OdbcCommand comm=new OdbcCommand();
			OdbcConnection con=dbcon2.getCon();
			comm.Connection=con;
			con.Open();
			comm.CommandText=sqlstring;
			comm.Parameters.Add("image",b);
			comm.ExecuteNonQuery();
			con.Close();

			//dbcon2.ExecuteNonQuery(sqlstring);

			MessageBox.Show(this,"保存成功!","酒店信息管理",MessageBoxButtons.OK,MessageBoxIcon.Information);
		}

		private void groupBox1_Enter(object sender, System.EventArgs e)
		{
		
		}
		
		/*
		static void Main() 
		{
			Application.Run(new frmEditHotel());
		}
		*/
	}
}

⌨️ 快捷键说明

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