Пример #1
0
        private void tlBtnSave_Click(object sender, EventArgs e)
        {
            //判断是添加还是修改数据
            if (G_Int_addOrUpdate == 0)
            {
                try
                {
                    //添加数据
                    employeeinfo.EmployeeCode = txtEmpployCode.Text;
                    employeeinfo.FullName     = txtFullName.Text;
                    employeeinfo.Sex          = cmbSex.Text;
                    employeeinfo.Dept         = txtDept.Text;
                    employeeinfo.Tel          = txtTel.Text;
                    employeeinfo.Memo         = txtMemo.Text;

                    //执行添加
                    int id = baseinfo.AddEmployee(employeeinfo);
                    MessageBox.Show("新增--公司职员数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                //修改数据
                employeeinfo.EmployeeCode = txtEmpployCode.Text;
                employeeinfo.FullName     = txtFullName.Text;
                employeeinfo.Sex          = cmbSex.Text;
                employeeinfo.Dept         = txtDept.Text;
                employeeinfo.Tel          = txtTel.Text;
                employeeinfo.Memo         = txtMemo.Text;

                //执行修改
                int id = baseinfo.UpdateEmployee(employeeinfo);
                MessageBox.Show("修改--公司职员数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            dgvEmployeeList.DataSource = baseinfo.GetAllEmployee("tb_employee").Tables[0].DefaultView;
            this.SetdgvEmployeeListHeadText();
            this.cancelEnabled();
        }