namespace Jxc
{
public partial class FormEmpUpdate : Form
{
public FormEmpUpdate()
{
InitializeComponent();
}
public Employee SomeEmp { get; set; }
private void FormEmpUpdate_Load(object sender, EventArgs e)
{
//修改前原信息
this.textEmpId.Text = SomeEmp.EmpId.ToString();
this.textEmpName.Text = SomeEmp.EmpName;
this.combEmpSex.Text = SomeEmp.EmpSex;
this.textEmpBirth.Text = SomeEmp.EmpBirth.ToString();
this.combProvince.Text = SomeEmp.EmpProvince;
this.textEmpCall.Text = SomeEmp.EmpCall;
this.textEmpAddress.Text = SomeEmp.EmpAddress;
this.txtphoto.Text = SomeEmp.EmpPhoto;
this.combEmpDepId.Text = SomeEmp.DepId.ToString();
this.combEmpStoId.Text = SomeEmp.StoId.ToString();
}
private void btnUpdateDetail_Click(object sender, EventArgs e)
{
int empId = Int32.Parse(this.textEmpId.Text);
string empName = this.textEmpName.Text;
string empSex = this.combEmpSex.Text;
DateTime empBirth = DateTime.Parse(this.textEmpBirth.Text);
string empCall = this.textEmpCall.Text;
string empProvince = this.combProvince.Text;
string empAddress = this.textEmpAddress.Text;
string empPhoto = this.txtphoto.Text;
int depId = Int32.Parse(this.combEmpDepId.Text);
int stoId = Int32.Parse(this.combEmpStoId.Text);
string strSql = "update employee set empName = '" + empName + "', empSex = '" + empSex + "', empBirth = '" + empBirth + "', empCall = '" + empCall + "', empProvince = '" + empProvince + "', empAddress = '" + empAddress + "', empPhoto = '" + empPhoto + "', depId = '" + depId + "', stoId = '" + stoId + "' where empId = '" + empId + "'";
string conString = "server=.;database=GXT;uid=sa;pwd=tian123";
SqlConnection con = new SqlConnection(conString);
con.Open();
SqlCommand cmd = new SqlCommand(strSql, con);
int jieguo = cmd.ExecuteNonQuery();
con.Close();
DialogResult xiugai = DialogResult.Yes;
if (jieguo > 0)
{
xiugai = MessageBox.Show("修改成功确认不再修改请按yes重新修改请按no", "修改", MessageBoxButtons.YesNo);
}
if (xiugai == DialogResult.No)
{
this.textEmpName.Text = "";
this.combEmpSex.Text = "";
this.textEmpBirth.Text = "";
this.combProvince.Text = "";
this.textEmpCall.Text = "";
this.textEmpAddress.Text = "";
this.txtphoto.Text = "";
this.combEmpDepId.Text = "";
this.combEmpStoId.Text = "";
}
else
{
this.Close();
}
}
}
}