protected void grvLib_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { try { TBL_QUYEN objVaitro = new TBL_QUYEN(); objVaitro.NAME = Convert.ToString(e.NewValues["NAME"]); objVaitro.DESCRIPTION = Convert.ToString(e.NewValues["DESCRIPTION"]); if (validation(objVaitro)) { entities.TBL_QUYEN.Add(objVaitro); entities.SaveChanges(); grvLib.CancelEdit(); //This line closes the line Editor. grvLib.Focus(); //Display Message Box Commons.ValidationFuncs.errorMessage_TimeDelay(Commons.TitleConst.getTitleConst("MSG_INSERT_SUCCESFULLY"), Page); } } catch (Exception ex) { //errorMsg.Text = "Lỗi: " + ex.Message + ex.InnerException + ex.StackTrace; // ghi log throw ex; } finally { e.Cancel = true; } }
/** * DESCRIPTION: This funtion check fomat before updating into DB * INPUTS: Menu is the object need updated into DB * OUTPUTS: TRUE if data is valid; FALSE if data is invalid * WRITTEN BY: TUYENDV **/ protected bool validation(TBL_QUYEN objMenu) { //Check whether TITLE is empty if (String.IsNullOrEmpty(objMenu.NAME)) { Commons.ValidationFuncs.errorMessage_TimeDelay(Commons.TitleConst.getTitleConst("MSG_TEN_VAI_TRO"), Page); return(false); } return(true); }