public UcInfo(DTO.NguyenLieu data) { InitializeComponent(); this.data = data; isUpdate = true; lbSelect.Text = Constant.DEFAULT_TITLE_EDIT; if (Init()) { tbMaNL.Text = data.MaNguyenLieu; tbTen.Text = data.Ten; cbDVTNL.Text = data.DonViTinh; if (data.IsActive) { rbSuDung.Checked = true; } else { rbTamNgung.Checked = true; } tbMoTa.Text = data.MoTa; } else { this.Visible = false; } }
public static bool Delete(NguyenLieu data, User user) { try { if (data != null) { NguyenLieu objDb = GetById(data.Id); if (objDb != null) { objDb.DeleteFlag = true; dbContext.SubmitChanges(); return true; } } } catch { } CreateSQlConnection(); return false; }
private void btnChon_Click(object sender, EventArgs e) { if (phieuNhapHang.NgayGiao != "" && phieuNhapHang.NgayGiao != null) { MessageBox.Show("Đơn đặt hàng đã giao bạn không được phép sửa"); return; } if (dGVNguyenLieu.CurrentRow != null) { int index = dGVNguyenLieu.CurrentRow.Index; string soHD = dGVNguyenLieu[5, index].Value.ToString(); DTO.NguyenLieu nguyenLieu = bindingListNguyenLieu[index]; if (hashMaHangHoa.Contains(nguyenLieu.Ma)) { for (int i = 0; i < bindingSource.Count; i++) { if (((PhieuNhapHangDataSource)bindingSource[i]).Ma == nguyenLieu.Ma) { index = i; break; } } dGVHoaDon[4, index].Value = int.Parse(dGVHoaDon[4, index].Value.ToString()) + 1; dGVHoaDon[5, index].Value = int.Parse(dGVHoaDon[3, index].Value.ToString()) * int.Parse(dGVHoaDon[4, index].Value.ToString()); TongCong = TongCong + nguyenLieu.Dongia; return; } string maHangHoa = nguyenLieu.Ma; hashMaHangHoa.Add(maHangHoa); bindingSource.Add(new PhieuNhapHangDataSource() { Ma = nguyenLieu.Ma, Ten = nguyenLieu.Ten, DonViTinh = nguyenLieu.DonViTinh, Gia = nguyenLieu.Dongia.ToString(), Loai = nguyenLieu.Loai, Soluong = "1", Thanhtien = nguyenLieu.Dongia.ToString(), }); TongCong = TongCong + nguyenLieu.Dongia; } }
public UcInfo() { InitializeComponent(); data = new DTO.NguyenLieu(); isUpdate = false; if (Init()) { RefreshData(); } else { this.Visible = false; } }
partial void DeleteNguyenLieu(NguyenLieu instance);
partial void UpdateNguyenLieu(NguyenLieu instance);
partial void InsertNguyenLieu(NguyenLieu instance);
private void InsertData() { data = new DTO.NguyenLieu(); data.MaNguyenLieu = tbMaNL.Text; data.Ten = tbTen.Text; data.DonViTinh = cbDVTNL.Text; data.HanMuc = ConvertUtil.ConvertToDouble(tbHanMuc.Text); data.IsActive = rbSuDung.Checked; data.MoTa = tbMoTa.Text; if (NguyenLieuBus.Insert(data, FormMain.user)) { ConfirmContinue(); } else { if (MessageBox.Show(string.Format(Constant.MESSAGE_INSERT_ERROR_DUPLICATED, tbTen.Text) + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { this.Dispose(); } } }
public static bool Update(NguyenLieu data, User user) { return NguyenLieuDao.Update(data, user); }
public static bool Insert(NguyenLieu data, User user) { return NguyenLieuDao.Insert(data, user); }
public static bool Delete(NguyenLieu data, User user) { return NguyenLieuDao.Delete(data, user); }
public static bool Update(NguyenLieu data, User user) { try { if (data != null) { dbContext.SubmitChanges(); return true; } return false; } catch { return false; } }
public static bool Insert(NguyenLieu data, User user) { try { if (GetByName(data.Ten) != null) { return false; } dbContext.NguyenLieus.InsertOnSubmit(data); dbContext.SubmitChanges(); return true; } catch { return false; } }