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(); }