• 修改前显示员工信息


    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();
                }
            }
        }
    }
  • 相关阅读:
    [.Net MVC] 使用 log4net 日志框架
    322作业
    uva 12171 sculpture (超级好题)——yhx
    NOIP2007 T2纪念品分组 解题报告-S.B.S.
    NOIP2007 T1奖学金 解题报告-S.B.S.
    NOIP2012普及组 (四年后的)解题报告 -SilverN
    calc 多项式计算 (STL版和非STL版) -SilverN
    uva 10562 undraw the trees(烂题) ——yhx
    uva 10129 play on words——yhx
    uva 10305 ordering tasks(超级烂题)——yhx
  • 原文地址:https://www.cnblogs.com/Tianxf815/p/8877626.html
Copyright © 2020-2023  润新知