Example #1
0
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            bool rv = false; // return value

            var emp = new EmpEntity
            {
                MANDT   = "001",
                EMPID   = txtEmpID.Text.Trim(),
                EMPNAME = txtName.Text.Trim(),
                EMPADDR = txtAddress.Text.Trim()
            };

            var empService = new EmpService();

            if (isAddNewMode)
            {
                try {
                    rv = empService.Create(emp);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                rv = empService.Update(emp);
            }

            if (rv)
            {
                empBs.EndEdit();
                this.Close();
            }
        }
Example #2
0
        private IList <EmpEntity> LoadEmployees()
        {
            var empService = new EmpService();
            IList <EmpEntity> employees = empService.ListAll();

            return(employees);
        }
Example #3
0
        private void DoDelete()
        {
            if (bindingSource1.Current == null)
            {
                return;
            }

            if (MessageBox.Show("确定删除这个员工吗?", "删除",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
            {
                var empId = (bindingSource1.Current as EmpEntity).EMPID;

                var  empService = new EmpService();
                bool rv         = empService.Delete(empId);
                if (rv)
                {
                    bindingSource1.RemoveCurrent(); // 保持界面同步
                }
            }
        }