private void btnXoa_Click(object sender, EventArgs e) { string maPhieuXuat = grvData.GetRowCellValue(grvData.FocusedRowHandle, "MaPX").ToString(); if (string.IsNullOrEmpty(maPhieuXuat)) { MessageBox.Show(string.Format("Vui lòng chọn bản ghi cần xóa!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("Bạn có muốn xóa bản ghi này không?", CommonConstant.MESSAGE_INFO, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { //Duyet ban ghi var model = db.PhieuXuats.Find(maPhieuXuat);; db.PhieuXuats.Remove(model); int record = db.SaveChanges(); if (record > 0) { MessageBox.Show("Xóa bản ghi thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadData(); }
private void btnDuyetPhieu_Click(object sender, EventArgs e) { string maVT = grvData.GetRowCellValue(grvData.FocusedRowHandle, "MaPhieuNhap").ToString(); if (string.IsNullOrEmpty(maVT)) { MessageBox.Show(string.Format("Vui lòng chọn bản ghi cần sửa!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("Bạn có muốn duyệt phiếu nhập này không?", CommonConstant.MESSAGE_INFO, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { //Duyet ban ghi var model = db.PhieuNhaps.Find(maVT);; model.TrangThai = CommonConstant.STATUS_DADUYET; model.NgayDuyet = DateTime.Now; model.NguoiDuyet = StaticValue.UserLogin.Email.Split('@')[0]; //Chuyen du lieu vao trong ChiTietKho InsertVaoKho(maVT, model.MaKhoVT); //End //update trang thai phieu KT UpdateStatusPKT(model.MaPhieuKT); //End int record = db.SaveChanges(); if (record > 0) { MessageBox.Show("Duyệt phiếu thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadData(); }
private void btnXoa_Click(object sender, EventArgs e) { object keyValue = tlstData.FocusedNode[tlstData.KeyFieldName]; string maNCC = keyValue.ToString(); if (string.IsNullOrEmpty(maNCC)) { MessageBox.Show(string.Format("Vui lòng chọn bản ghi cần sửa!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("Bạn có muốn xóa bản ghi này không?", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { SelectedCbx sel = new SelectedCbx(); //kiem tra xem co don vi con khong if (sel.CheckChildExist(maNCC)) { MessageBox.Show("Đơn vị đã tồn tại đơn vị con. Vui lòng xóa các đơn vị con của đơn vị này!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var model = db.PXTDs.Find(maNCC);; db.PXTDs.Remove(model); int record = db.SaveChanges(); if (record > 0) { MessageBox.Show("Xóa bản ghi thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadData(); }
private void Save() { if (dtpNgayLap.Value.CompareTo(DateTime.Now) > 0) { MessageBox.Show("Ngày lập không được lớn hơn ngày hiện tại!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.PhieuXuats.Find(txtMaPX.Text); model.NgayLap = dtpNgayLap.Value; model.MaKhoNhap = cbxKhoYC.SelectedValue.ToString(); model.MaKhoXuat = cbxKhoXuat.SelectedValue.ToString(); model.NoiDung = txtMoTa.Text; if (cbxPhieuYC.SelectedValue != null) { model.PhieuYC = cbxPhieuYC.SelectedValue.ToString(); } else { model.PhieuYC = null; } info = "Sửa thông tin phiếu xuất"; } else { PhieuXuat obj = new PhieuXuat(); obj.MaPX = GenerateID(); obj.NgayLap = dtpNgayLap.Value; obj.MaKhoNhap = cbxKhoYC.SelectedValue.ToString(); obj.MaKhoXuat = cbxKhoXuat.SelectedValue.ToString(); obj.NoiDung = txtMoTa.Text; if (cbxPhieuYC.SelectedValue != null) { obj.PhieuYC = cbxPhieuYC.SelectedValue.ToString(); } obj.TrangThai = CommonConstant.STATUS_MOI; obj.NguoiLap = StaticValue.UserLogin.Email.Split('@')[0]; info = "Thêm mới phiếu xuất"; db.PhieuXuats.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { if (string.IsNullOrEmpty(txtSerialNumber.Text.Trim())) { MessageBox.Show("Serial Number không được để trống!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { int.Parse(txtSoLuong.Text.Trim()); } catch (Exception) { MessageBox.Show("Số lượng không hợp lệ! Vui lòng kiểm tra lại!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.ChiTietPhieuKTs.Find(ID); model.SerialNumber = txtSerialNumber.Text.Trim(); model.SoLuong = int.Parse(txtSoLuong.Text.Trim()); model.TrangThaiKT = int.Parse(cbxTTKT.SelectedValue.ToString()); model.MaVT = cbxVatTu.SelectedValue.ToString(); model.MoTa = txtMoTa.Text; model.TrangThaiVT = cbxTTVT.SelectedValue.ToString(); info = "Sửa thông tin phiếu kiểm tra"; } else { ChiTietPhieuKT obj = new ChiTietPhieuKT(); obj.SerialNumber = txtSerialNumber.Text.Trim(); obj.SoLuong = int.Parse(txtSoLuong.Text.Trim()); obj.TrangThaiKT = int.Parse(cbxTTKT.SelectedValue.ToString()); obj.MaVT = cbxVatTu.SelectedValue.ToString(); obj.MaPhieuKT = StaticValue.MaPhieuKT; obj.MoTa = txtMoTa.Text; obj.TrangThaiVT = cbxTTVT.SelectedValue.ToString(); info = "Thêm mới chi tiết phiếu kiểm tra"; db.ChiTietPhieuKTs.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { if (dtpNgayLap.Value.CompareTo(DateTime.Now) > 0) { MessageBox.Show("Ngày lập không được lớn hơn ngày hiện tại!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string text = cbxNguoiTG.Text; string info = ""; if (flag)//sua ban ghi { var model = db.PhieuKTs.Find(txtMaPKT.Text); model.NgayLap = dtpNgayLap.Value; if (!string.IsNullOrEmpty(Text)) { model.NguoiThamGia = cbxNguoiTG.Text; } else { model.NguoiThamGia = null; } info = "Sửa thông tin phiếu kiểm tra"; } else { PhieuKT obj = new PhieuKT(); obj.MaPhieuKT = GenerateID(); obj.NgayLap = dtpNgayLap.Value; if (!string.IsNullOrEmpty(Text)) { obj.NguoiThamGia = cbxNguoiTG.Text; } else { obj.NguoiThamGia = null; } obj.TrangThai = CommonConstant.STATUS_MOI; obj.NguoiLap = StaticValue.UserLogin.Email.Split('@')[0]; info = "Thêm mới phiếu kiểm tra"; db.PhieuKTs.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { if (string.IsNullOrEmpty(txtTenNCC.Text.Trim())) { MessageBox.Show("Tên nhà cung cấp không được để trống.", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!CommonConstant.CheckPhoneNumber(txtSDT.Text)) { MessageBox.Show("Số điện thoại không hợp lệ.", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.NhaCungCaps.Find(txtMaNCC.Text); model.TenNCC = txtTenNCC.Text; model.TenNCC = txtTenNCC.Text; model.SDT = txtSDT.Text; model.MoTa = txtMoTa.Text; model.MST = txtMST.Text; model.DiaChi = txtDiaChi.Text; model.Email = txtEmail.Text; info = "Sửa thông tin nhà cung cấp"; } else { NhaCungCap obj = new NhaCungCap(); obj.MaNCC = GenerateID(); obj.TenNCC = txtTenNCC.Text; obj.SDT = txtSDT.Text; obj.MoTa = txtMoTa.Text; obj.MST = txtMST.Text; obj.DiaChi = txtDiaChi.Text; obj.Email = txtEmail.Text; info = "Thêm mới thông tin nhà cung cấp"; db.NhaCungCaps.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { if (string.IsNullOrEmpty(txtTenVT.Text.Trim())) { MessageBox.Show("Tên vật tư không được để trống.", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.VatTus.Find(txtMaVT.Text); model.TenVT = txtTenVT.Text; model.DonGia = decimal.Parse(txtDonGia.Text); model.DVT = cbxDVT.Text; model.MoTa = txtMoTa.Text; model.MaLoaiVT = cbxLoaiVT.SelectedValue.ToString(); model.MaNCC = cbxNhaCC.SelectedValue.ToString(); info = "Sửa thông tin vật tư"; } else { VatTu model = new VatTu(); model.MaNCC = GenerateID(); model.TenVT = txtTenVT.Text; model.DonGia = decimal.Parse(txtDonGia.Text); model.DVT = cbxDVT.Text; model.MoTa = txtMoTa.Text; model.MaLoaiVT = cbxLoaiVT.SelectedValue.ToString(); model.MaNCC = cbxNhaCC.SelectedValue.ToString(); info = "Thêm mới Vật tư"; db.VatTus.Add(model); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { if (string.IsNullOrEmpty(txtTenDV.Text.Trim())) { MessageBox.Show("Tên đơn vị không được để trống.", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.PXTDs.Find(txtMaDV.Text); model.TenPXTD = txtTenDV.Text; model.GhiChu = txtMoTa.Text; model.ParentID = cbxParentID.SelectedValue.ToString().Equals("")? null : cbxParentID.SelectedValue.ToString(); info = "Sửa thông tin đơn vị"; } else { PXTD model = new PXTD(); model.MaPXTD = GenerateID(); model.TenPXTD = txtTenDV.Text; model.GhiChu = txtMoTa.Text; model.ParentID = cbxParentID.SelectedValue.ToString().Equals("") ? null : cbxParentID.SelectedValue.ToString(); info = "Thêm mới đơn vị"; db.PXTDs.Add(model); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { try { int.Parse(txtSoLuong.Text.Trim()); } catch (Exception) { MessageBox.Show("Số lượng không hợp lệ! Vui lòng kiểm tra lại!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.ChiTietPhieuYCs.Find(ID); model.SoLuong = int.Parse(txtSoLuong.Text.Trim()); model.MaVT = cbxVatTu.SelectedValue.ToString(); model.MoTa = txtMoTa.Text; info = "Sửa thông tin phiếu yêu cầu"; } else { ChiTietPhieuYC obj = new ChiTietPhieuYC(); obj.SoLuong = int.Parse(txtSoLuong.Text.Trim()); obj.MaVT = cbxVatTu.SelectedValue.ToString(); obj.MoTa = txtMoTa.Text; info = "Thêm mới chi tiết phiếu yêu cầu"; db.ChiTietPhieuYCs.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa bản ghi này không?", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string maNCC = grvData.GetRowCellValue(grvData.FocusedRowHandle, "MaNCC").ToString(); var model = db.NhaCungCaps.Find(maNCC);; db.NhaCungCaps.Remove(model); int record = db.SaveChanges(); if (record > 0) { MessageBox.Show("Xóa bản ghi thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadData(); }
private void Save() { if (string.IsNullOrEmpty(txtTenLVT.Text.Trim())) { MessageBox.Show("Tên nhà cung cấp không được để trống.", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; if (flag)//sua ban ghi { var model = db.LoaiVatTus.Find(txtMaLVT.Text); model.TenLoaiVT = txtTenLVT.Text; model.MaLoaiVT = txtMaLVT.Text; model.MoTa = txtMoTa.Text; info = "Sửa thông tin loại vật tư"; } else { LoaiVatTu obj = new LoaiVatTu(); obj.MaLoaiVT = GenerateID(); obj.TenLoaiVT = txtTenLVT.Text; obj.MoTa = txtMoTa.Text; info = "Thêm mới loại vật tư"; db.LoaiVatTus.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void ChangePassword() { string newPass = txtPasswordNew.Text; string againPass = txtPasswordAgain.Text; //Neu password moi khong trung nhau if (!newPass.ToLower().Equals(againPass.ToLower())) { MessageBox.Show("Mật khẩu mới không trùng nhau! Vui lòng kiểm tra lại", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var model = (from m in db.NhanViens where m.MaNV == txtAccount.Text && m.Password == txtPasswordOld.Text select m).FirstOrDefault(); if (model == null || string.IsNullOrEmpty(model.TenNV)) { MessageBox.Show("Tài khoản hoặc mật khẩu không chính xác! Vui lòng kiểm tra lại", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // thuc hien edit model.Password = txtPasswordNew.Text; int record = db.SaveChanges(); if (record > 0) { MessageBox.Show("Đổi mật khẩu thành công! vui lòng đăng nhập lại để sử dụng hệ thống!", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); //clear cache neu co' StaticValue.UserLogin = new NhanVien(); // this.Close(); frmDangNhap frm = new frmDangNhap(); frm.Show(); } else { MessageBox.Show("Có lỗi xảy ra khi thực hiện đổi mật khẩu! Vui lòng kiểm tra lại", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Save() { if (string.IsNullOrEmpty(txtTenNV.Text.Trim())) { MessageBox.Show("Tên vật tư không được để trống.", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!string.IsNullOrEmpty(Path_Image)) { var model = db.NhanViens.Select(m => m.Avatar == @"\images\" + Path_Image).FirstOrDefault(); if (model) { MessageBox.Show("Tên ảnh đã tồn tại trong hệ thống. Vui lòng kiểm tra lại!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); picAva.Image = null; Path_Image = ""; return; } } string info = ""; if (flag)//sua ban ghi { var model = db.NhanViens.Find(txtMaNV.Text); model.ChucVu = txtChucVu.Text; model.DiaChi = txtDiaChi.Text; model.Email = txtEmail.Text; model.MoTa = txtMoTa.Text; //model.MaNV = txtMaNV.Text; model.PhongBan = cbxDonVi.SelectedValue.ToString(); model.RoleID = cbxQuyen.Text; model.GioiTinh = rptNam.Checked ? true : rptNu.Checked ? false : false; model.NgaySinh = dtpNgaySinh.Value; model.TenNV = txtTenNV.Text; if (!string.IsNullOrEmpty(Path_Image)) { CopyImage(Path_Image, true); model.Avatar = @"\images\" + Path_Image; } info = "Sửa thông tin nhân viên"; } else { NhanVien model = new NhanVien(); model.MaNV = GenerateID(); model.ChucVu = txtChucVu.Text; model.DiaChi = txtDiaChi.Text; model.Email = txtEmail.Text; model.MoTa = txtMoTa.Text; model.PhongBan = cbxDonVi.SelectedValue.ToString(); model.RoleID = cbxQuyen.Text; model.GioiTinh = rptNam.Checked ? true : rptNu.Checked ? false : false; model.NgaySinh = dtpNgaySinh.Value; model.TenNV = txtTenNV.Text; model.Password = "******"; if (!string.IsNullOrEmpty(Path_Image)) { CopyImage(Path_Image, true); //model.Avatar = @"\images\" + Path_Image; } info = "Thêm mới nhân viên"; db.NhanViens.Add(model); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void Save() { if (dtpNgayLap.Value.CompareTo(DateTime.Now) > 0) { MessageBox.Show("Ngày lập không được lớn hơn ngày hiện tại!", CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string info = ""; string strMaPNhap = txtMaPNhap.Text; string strMaPhieuKT = cbxPhieuKT.SelectedValue.ToString(); if (flag)//sua ban ghi { var model = db.PhieuNhaps.Find(strMaPNhap); model.NgayLap = dtpNgayLap.Value; model.MaKhoVT = cbxKhoVT.SelectedValue.ToString(); model.MaPhieuKT = strMaPhieuKT; model.MaNCC = cbxNCC.SelectedValue.ToString(); model.NoiDung = txtMoTa.Text; if (string.IsNullOrEmpty(mstrOLdValueMaKT) || !mstrOLdValueMaKT.Equals(cbxPhieuKT.SelectedValue.ToString())) { //Clear bang chitiet phieu nhap ClearDataChiTiet(strMaPNhap); //Cap nhat lai chi tiet phieu nhap UpdateChiTiet(strMaPNhap, strMaPhieuKT); //end } info = "Sửa thông tin phiếu nhập"; } else { strMaPNhap = GenerateID(); PhieuNhap obj = new PhieuNhap(); obj.MaPhieuNhap = strMaPNhap; obj.NgayLap = dtpNgayLap.Value; obj.TrangThai = CommonConstant.STATUS_MOI; obj.NguoiLap = StaticValue.UserLogin.Email.Split('@')[0]; obj.MaKhoVT = cbxKhoVT.SelectedValue.ToString(); obj.MaPhieuKT = cbxPhieuKT.SelectedValue.ToString(); obj.MaNCC = cbxNCC.SelectedValue.ToString(); obj.NoiDung = txtMoTa.Text; //Insert chi tiet phieu nhap UpdateChiTiet(strMaPNhap, strMaPhieuKT); //end info = "Thêm mới phiếu nhập"; db.PhieuNhaps.Add(obj); } int record = db.SaveChanges(); if (record > 0) { MessageBox.Show(info + " thành công.", CommonConstant.MESSAGE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(string.Format("Xảy ra lỗi, vui lòng kiểm tra lại!"), CommonConstant.MESSAGE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }