示例#1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                int      MaNV     = int.Parse(txtEmpID.Text);
                string   HoTen    = txtFullName.Text;
                int      MaCV     = int.Parse(cbJob.SelectedValue.ToString());
                string   UserName = cbUserName.SelectedValue.ToString();
                string   GioiTinh = cbGender.SelectedItem.ToString();
                int      Luong    = int.Parse(txtLuong.Text);
                string   DiaChi   = txtHomeAddress.Text;
                int      Tuoi     = int.Parse(txtAge.Text);
                DateTime NgayBD   = dtpkNgayBD.Value;

                string status = Employee.Update(MaNV, HoTen, GioiTinh, Tuoi, DiaChi, NgayBD, Luong, UserName, MaCV);
                if (status != "Successful")
                {
                    throw new Exception(status);
                }
                MessageBox.Show("Cập nhật thành công", "STATUS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadData();
                Reset();
            }
            catch (FormatException exception)
            {
                MessageBox.Show("Mã không hợp lệ!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        public ActionResult Edit(EmployeeModel emp)
        {
            if (ModelState.IsValid)
            {
                var bal = new EmployeeBAL();
                bal.Update(emp);
                return(RedirectToAction("Index", "Employee"));
            }

            else
            {
                return(View());
            }
        }