private void simpleButtonSua_Click(object sender, EventArgs e) { int soluong = Convert.ToInt32(textEditSoLuong.Text); DataRow drReview = gridViewCTPGC_review.GetDataRow(gridViewCTPGC_review.FocusedRowHandle); BUL_CTPDV bulCtpdv = new BUL_CTPDV(); int slTrenPdv = bulCtpdv.GetSoLuongById(Convert.ToInt32(drReview["Id"])); if (soluong > slTrenPdv) { MessageBox.Show(Resources.SuaPhieuGiaCong_SoLuongNhapGCToiDa + Resources.SuaPhieuGiaCong_SLToiDaCoTheNhap + slTrenPdv, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } BUL_CTPGC bulCtpgc = new BUL_CTPGC(); CTPGC ctpgc = new CTPGC(); ctpgc.Id = Convert.ToInt32(drReview["Id"]); ctpgc.SoPhieuGC = _soPGC; ctpgc.TrongLuong = 0.1; ctpgc.SoLuong = Convert.ToInt32(soluong); ctpgc.TienCong = Convert.ToInt32(textEditTienCong.Text); ctpgc.ThanhTien = Convert.ToDecimal(textEditTongTien.Text); bulCtpgc.UpdateCTPGC(ctpgc); MessageBox.Show(Resources.SuaPhieuGiaCong_SuaCTPGCThanhCong, Resources.TitleMessageBox_ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information); LoadCtpgc_review(); LoadCtpdvCanGiaCong(); }
private void simpleButtonThem_Click(object sender, EventArgs e) { if (!CheckLogicError()) { return; } string soLuong = textEditSoLuong.Text; string tienCong = textEditTienCong.Text; string thanhTien = textEditThanhTien.Text; DataRow currentRow = gridViewCTSPGC.GetDataRow(gridViewCTSPGC.FocusedRowHandle); CTPGC ctpgc = new CTPGC { SoPhieuGC = _soPGC, Id = Convert.ToInt32(currentRow["Id"]), SoLuong = Convert.ToInt32(soLuong), TrongLuong = 0.1, TienCong = Convert.ToInt32(tienCong), ThanhTien = Convert.ToInt32(thanhTien) }; BUL_CTPGC bulCtpgc = new BUL_CTPGC(); DataRow drReview = _dataTableCtpgcReview.Select("Id=" + currentRow["Id"]).FirstOrDefault(); //Neu da co trong datatable_review thi se cong them so luong va cap nhat tien cong //moi nhat vao. Neu chua co thi moi add dong moi if (drReview != null) { ctpgc.SoLuong += Convert.ToInt32(drReview["SoLuong"]); ctpgc.TienCong = Convert.ToInt32(tienCong); ctpgc.ThanhTien = ctpgc.SoLuong * ctpgc.TienCong; bulCtpgc.UpdateCTPGC(ctpgc); } else { bulCtpgc.AddNewCTPGC(ctpgc); } //Neu ok het MessageBox.Show(Resources.SuaPhieuGiaCong_ThemCTPGCThanhCong, Resources.TitleMessageBox_ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information); //LoadInfoCTPDV(); _isResultOk = true; //UpdateDataTableCTSPCanGiaCong LoadCtpdvCanGiaCong(); LoadCtpgc_review(); }
private void simpleButtonLuu_Click(object sender, EventArgs e) { //Check logic condition if (comboBoxEditTenTho.SelectedIndex == -1) { MessageBox.Show(Resources.NhapPhieuGiaCong_TenThoEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); comboBoxEditTenTho.Focus(); return; } if (dateEditNgayNhanHang.Text.Equals("")) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayNhanHangEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayNhanHang.Focus(); return; } if (dateEditNgayThanhToan.Text.Equals("")) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayThanhToanEmpty, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayThanhToan.Focus(); return; } if (dateEditNgayNhanHang.DateTime != DateTime.Today) { MessageBox.Show(Resources.NgNhanHang, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayNhanHang.Focus(); return; } if (dateEditNgayNhanHang.DateTime > dateEditNgayThanhToan.DateTime) { MessageBox.Show(Resources.NhapPhieuGiaCong_NgayThanhToanTruocNgayNhanHang, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); dateEditNgayThanhToan.Focus(); return; } if (_dataTableCtpgcReview.Rows.Count == 0) { MessageBox.Show(Resources.NhapPhieuGiaCong_SLChiTietPGCToiThieu, Resources.TitleMessageBox_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Create PGC BUL_PhieuGiaCong bulPhieuGiaCong = new BUL_PhieuGiaCong(); PHIEUGIACONG phieugiacong = new PHIEUGIACONG(); phieugiacong.NgayNhanHang = dateEditNgayNhanHang.DateTime; phieugiacong.NgayThanhToan = dateEditNgayThanhToan.DateTime; phieugiacong.MaTho = ((THO)((ContainerItem)comboBoxEditTenTho.SelectedItem).Value).MaTho; phieugiacong.TongTien = Convert.ToDecimal(textEditTongTien.Text); phieugiacong.MaNV = _maNV; int sophieuGc = bulPhieuGiaCong.AddNewPhieuGiaCong(phieugiacong); //Create CTPGC BUL_CTPGC bulCtpgc = new BUL_CTPGC(); foreach (DataRow dtRow in _dataTableCtpgcReview.Rows) { CTPGC ctpgc = new CTPGC(); ctpgc.SoPhieuGC = sophieuGc; ctpgc.Id = Convert.ToInt32(dtRow["Id"]); ctpgc.SoLuong = Convert.ToInt32(dtRow["SoLuong"]); ctpgc.TienCong = Convert.ToDecimal(dtRow["TienCong"]); ctpgc.ThanhTien = Convert.ToDecimal(dtRow["ThanhTien"]); ctpgc.TrongLuong = 0.1; bulCtpgc.AddNewCTPGC(ctpgc); } //Neu ok het MessageBox.Show(Resources.NhapPhieuGiaCong_TaoPGCThanhCong, Resources.TitleMessageBox_ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information); simpleButtonLuu.Enabled = false; simpleButtonThem.Enabled = false; simpleButtonXoa.Enabled = false; _isResultOk = true; Close(); }