?? formmodifyemployee.cs
字號:
this.numLevel.Location = new System.Drawing.Point(144, 240);
this.numLevel.Name = "numLevel";
this.numLevel.Size = new System.Drawing.Size(100, 21);
this.numLevel.TabIndex = 18;
this.numLevel.Value = new System.Decimal(new int[] {
1,
0,
0,
0});
//
// picPhoto
//
this.picPhoto.Image = ((System.Drawing.Image)(resources.GetObject("picPhoto.Image")));
this.picPhoto.Location = new System.Drawing.Point(24, 24);
this.picPhoto.Name = "picPhoto";
this.picPhoto.Size = new System.Drawing.Size(112, 128);
this.picPhoto.TabIndex = 0;
this.picPhoto.TabStop = false;
//
// buttonUploadPhoto
//
this.buttonUploadPhoto.Location = new System.Drawing.Point(40, 168);
this.buttonUploadPhoto.Name = "buttonUploadPhoto";
this.buttonUploadPhoto.TabIndex = 1;
this.buttonUploadPhoto.Text = "上傳照片";
this.buttonUploadPhoto.Click += new System.EventHandler(this.buttonUploadPhoto_Click);
//
// btnUpdateEmployee
//
this.btnUpdateEmployee.Location = new System.Drawing.Point(288, 352);
this.btnUpdateEmployee.Name = "btnUpdateEmployee";
this.btnUpdateEmployee.TabIndex = 20;
this.btnUpdateEmployee.Text = "修改";
this.btnUpdateEmployee.Click += new System.EventHandler(this.btnUpdateEmployee_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(416, 352);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 21;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.picPhoto);
this.groupBox1.Controls.Add(this.buttonUploadPhoto);
this.groupBox1.Location = new System.Drawing.Point(296, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(160, 208);
this.groupBox1.TabIndex = 22;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "照片";
//
// label6
//
this.label6.Location = new System.Drawing.Point(48, 248);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(80, 23);
this.label6.TabIndex = 23;
this.label6.Text = "級別";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
this.pictureBox1.TabIndex = 24;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(8, 56);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(24, 24);
this.pictureBox2.TabIndex = 25;
this.pictureBox2.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.Location = new System.Drawing.Point(8, 144);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(24, 32);
this.pictureBox3.TabIndex = 26;
this.pictureBox3.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(8, 192);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(32, 32);
this.pictureBox4.TabIndex = 27;
this.pictureBox4.TabStop = false;
//
// pictureBox5
//
this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
this.pictureBox5.Location = new System.Drawing.Point(272, 288);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(40, 32);
this.pictureBox5.TabIndex = 28;
this.pictureBox5.TabStop = false;
//
// FormModifyEmployee
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(552, 405);
this.Controls.Add(this.pictureBox5);
this.Controls.Add(this.pictureBox4);
this.Controls.Add(this.pictureBox3);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label6);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnUpdateEmployee);
this.Controls.Add(this.numLevel);
this.Controls.Add(this.txtTel);
this.Controls.Add(this.txtPos);
this.Controls.Add(this.txtBaseSalary);
this.Controls.Add(this.txtEmail);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.txtUserName);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormModifyEmployee";
this.Text = "修改員工信息";
((System.ComponentModel.ISupportInitialize)(this.numLevel)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close ();
}
private void buttonUploadPhoto_Click(object sender, System.EventArgs e)
{
FormPhotoPath frmNewPhotoPath = new FormPhotoPath();
frmNewPhotoPath.ShowDialog();
imgb=frmNewPhotoPath.imgb;
this.picPhoto.Image=frmNewPhotoPath.picPhoto.Image;
}
private void btnUpdateEmployee_Click(object sender, System.EventArgs e)
{
if(IsNumber(this.txtBaseSalary.Text)&&IsNumber(this.txtTel.Text))
{
if(this.txtName.Text=="" || this.txtUserName.Text=="" || this.txtPassword.Text=="" || this.txtEmail.Text=="" || this.txtBaseSalary.Text=="" || this.txtPos.Text==""||this.txtTel.Text=="")
{
MessageBox.Show("請正確完整輸入!");
}
else
{
conn=new SqlConnection("Initial Catalog=BlueHill;Data Source=(local);Trusted_Connection=Yes");
adp=new SqlDataAdapter("select * from tblEmployee",conn);
conn.Open();
string haveimgb="update tblEmployee set Name=@Name,LoginName=@LoginName,Email=@Email,BasicSalary=@BasicSalary,Title=@Title,PhotoImage=@photo,Telephone=@Telephone where EmployeeID=@id";
string notimgb="update tblEmployee set Name=@Name,LoginName=@LoginName,Email=@Email,BasicSalary=@BasicSalary,Title=@Title,Telephone=@Telephone where EmployeeID=@id";
if(imgb==null)
{
com=new SqlCommand(notimgb,conn);
}
else
{
com=new SqlCommand(haveimgb,conn);
com.Parameters.Add("@photo",SqlDbType.Image);
com.Parameters["@photo"].Value=imgb;
}
dts = new DataSet();
adp.Fill(dts,"tblemployee");
dt=dts.Tables["tblemployee"];
DataRow selectedRow = dt.Rows[grd.CurrentCell.RowNumber];
int id=(int)selectedRow[0];
com.Parameters.Add("@Name",SqlDbType.NVarChar,24);
com.Parameters.Add("@LoginName",SqlDbType.NVarChar,20);
com.Parameters.Add("@Email",SqlDbType.NVarChar,50);
com.Parameters.Add("@BasicSalary",SqlDbType.Int,4);
com.Parameters.Add("@Title",SqlDbType.NVarChar,30);
com.Parameters.Add("@Telephone",SqlDbType.NVarChar,20);
com.Parameters.Add("@id",SqlDbType.Int,4);
com.Parameters["@id"].Value=id;
com.Parameters["@Name"].Value=this.txtName.Text;
com.Parameters["@LoginName"].Value=this.txtUserName.Text;
com.Parameters["@Email"].Value=this.txtEmail.Text;
com.Parameters["@BasicSalary"].Value=this.txtBaseSalary.Text;
com.Parameters["@Title"].Value=this.txtPos.Text;
com.Parameters["@Telephone"].Value=this.txtTel.Text;
int a=com.ExecuteNonQuery();
if(a>0)
{
MessageBox.Show("修改成功");
}
conn.Close();
this.Close();
}
}
else
{
MessageBox.Show("請正確填寫字符!!");
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -