private void buttonLuu_Click(object sender, EventArgs e) { if (HelpNumber.ParseInt32(colTienDoThuHien.SummaryItem.SummaryValue) == 100) { HelpMsgBox.ShowNotificationMessage("Công việc đã hoàn thành.Không thể cập nhật thêm tiến độ!"); this.Close(); return; } if (ztbarTienDoThucHien.Value == 0) { Error.SetError(ztbarTienDoThucHien, "Tiến độ phải lớn hơn 0!"); return; } DOChiTietPhanCong chiTietPhanCong = new DOChiTietPhanCong(PCCV_ID, NV_ID, DACongViec.getPhanTramThamGia(NV_ID, PCCV_ID), HelpNumber.ParseInt32(colTienDoThuHien.SummaryItem.SummaryValue) + ztbarTienDoThucHien.Value, HelpDB.getDatabase().GetSystemCurrentDateTime(), memoGhiChu.Text); if (DACongViec.luuCapNhatTienDo(chiTietPhanCong)) { if (RefreshData != null) RefreshData(); this.Close(); } else HelpMsgBox.ShowNotificationMessage("Lưu không thành công."); }
public static bool luuCapNhatTienDo(DOChiTietPhanCong chiTietPC) { DatabaseFB db = HelpDB.getDatabase(); DbTransaction tran = db.BeginTransaction(db.OpenConnection()); try { DbCommand cmd = db.GetSQLStringCommand(SQL_STRING_INSERT_CTPC); db.AddInParameter(cmd, "@PCCV_ID", DbType.Int64, chiTietPC.PCCV_ID); db.AddInParameter(cmd, "@MANV", DbType.Int64, chiTietPC.MA_NV); db.AddInParameter(cmd, "@PHAN_TRAM_THAM_GIA", DbType.Int32, chiTietPC.PHAN_TRAM_THAM_GIA); db.AddInParameter(cmd, "@TIEN_DO", DbType.Int32, chiTietPC.TIEN_DO); db.AddInParameter(cmd, "@THOI_GIAN_CAP_NHAT", DbType.DateTime, chiTietPC.THOI_GIAN_CAP_NHAT); db.AddInParameter(cmd, "GHI_CHU", DbType.String, chiTietPC.GHI_CHU); db.ExecuteNonQuery(cmd, tran); } catch(Exception ex) { PLException.AddException(ex); tran.Rollback(); return false; } finally { tran.Commit(); } return true; }