private void buttonLuu_Click(object sender, EventArgs e) { if (!HelpInputData.ShowRequiredError(Error, new object[] { memoGhiChu, "Nội dung" })) return; DONhatKyCongViec nhatKycongViec = new DONhatKyCongViec(HelpDB.getDatabase().GetID("GEN_ID_NHAT_KY"), PCCV_ID, NV_ID, HelpDB.getDatabase().GetSystemCurrentDateTime(), memoGhiChu.Text); if (DACongViec.luuNhatKyCongViec(nhatKycongViec)) { if (RefreshData != null) RefreshData(); this.Close(); } else HelpMsgBox.ShowNotificationMessage("Lưu không thành công."); }
public static bool luuNhatKyCongViec(DONhatKyCongViec nhatKyCV) { DatabaseFB db = HelpDB.getDatabase(); DbTransaction tran = db.BeginTransaction(db.OpenConnection()); try { DbCommand cmd = db.GetSQLStringCommand(SQL_STRING_INSERT_NKCV); db.AddInParameter(cmd, "@ID", DbType.Int64, nhatKyCV.ID); db.AddInParameter(cmd, "@PCCV_ID", DbType.Int64, nhatKyCV.PCCV_ID); db.AddInParameter(cmd, "@MANV", DbType.Int64, nhatKyCV.MA_NV); db.AddInParameter(cmd, "@THOI_GIAN_CAP_NHAT", DbType.DateTime, nhatKyCV.THOI_GIAN_CAP_NHAT); db.AddInParameter(cmd, "GHI_CHU", DbType.String, nhatKyCV.GHI_CHU); db.ExecuteNonQuery(cmd, tran); } catch (Exception ex) { PLException.AddException(ex); tran.Rollback(); return false; } finally { tran.Commit(); } return true; }