private void btnLuu_Click(object sender, EventArgs e)
 {
     /* Save new value to the database or update the existing value */
     obj.MaNhanVien = int.Parse(txtMa.Text);
     obj.Ten        = txtTen.Text;
     obj.NgaySinh   = dtNgaySinh.Value;
     obj.DiaChi     = txtDiaChi.Text;
     obj.ChucVu     = txtChucVu.Text;
     obj.Cmnd       = txtCMND.Text;
     obj.Luong      = int.Parse(spinLuong.Text);
     obj.NgayTuyen  = dtNgayTuyen.Value;
     bus.Update(obj);
     ClearField();
     Display();
     LockControl();
 }
Exemplo n.º 2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NhanVien obj = new NhanVien();

            try
            {
                if (txtTen.Text != "")
                {
                    obj.TENNV = txtTen.Text;
                }
                if (cbGT.SelectedItem.ToString() != "")
                {
                    obj.GT = cbGT.SelectedItem.ToString();
                }
                if (deNgaySinh.EditValue.ToString() != "")
                {
                    obj.NGAYSINH = Convert.ToDateTime(Convert.ToDateTime(deNgaySinh.EditValue.ToString()).ToString("yyyy/MM/dd"));
                }
                if (txtDienThoai.Text != "")
                {
                    obj.DIENTHOAI = txtDienThoai.Text;
                }
                if (txtDiaChi.Text != "")
                {
                    obj.DIACHI = txtDiaChi.Text;
                }
                if (txtTaiKhoan.Text != "")
                {
                    obj.TAIKHOAN = txtTaiKhoan.Text;
                }
                if (txtMatKhau.Text != "")
                {
                    obj.MATKHAU = txtMatKhau.Text;
                }
                if (txtEmail.Text != "")
                {
                    obj.EMAIL = txtEmail.Text;
                }
                if (lkQuyen.EditValue.ToString() != "")
                {
                    obj.MAQUYEN = int.Parse(lkQuyen.EditValue.ToString());
                }
            }
            catch { }
            //obj.NGAYSINH = Convert.ToDateTime(DateTime.ParseExact(deNgaySinh.EditValue.ToString(), "dd/MM/yyyy", new CultureInfo("fr-FR")).ToString("yyyy/MM/dd"));

            if (isThem)
            {
                bus.Insert(obj);
                XtraMessageBox.Show("Thêm thành công!");
                show();
                lockControl();
            }
            else
            {
                obj.MANV = int.Parse(txtMa.Text);
                bus.Update(obj);
                XtraMessageBox.Show("Lưu thành công!");
                show();
                lockControl();
            }
            isThem = false;
        }