public ActionResult SaveLookupMaster(DOCMN_LookupMaster objDOCMN_LookupMaster) { errorMessage = string.Empty; ExceptionTypes result = new ExceptionTypes(); try { long loginUserId = currentUser.ADM_UserMasterId; string returnMessage = string.Empty; if (objDOCMN_LookupMaster.CMN_LookupMasterId > 0) { BLCommon objCommon = new BLCommon(); if (!objCommon.ValidateLockBeforeSave(loginUserId, (long)ScreenType.LookupType, objDOCMN_LookupMaster.CMN_LookupTypeRef)) { errorMessage = "Record not locked, please reload the page."; result = ExceptionTypes.UnknownError; return(Json(new { ID = result, Message = errorMessage })); } objDOCMN_LookupMaster.LastUpdatedByRef = loginUserId; returnMessage = "Record updated successfully."; } else { objDOCMN_LookupMaster.CreatedByRef = loginUserId; returnMessage = "Record saved successfully."; } result = _objBLLookup.SaveLookupMaster(objDOCMN_LookupMaster, out errorMessage); if (result != (long)ExceptionTypes.Success) { BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Lookups, (long)ExceptionTypes.Uncategorized, string.Empty, errorMessage); return(Json(new { ID = result, Message = "An error occured while updating DB." })); } return(Json(new { ID = result, Message = returnMessage })); } catch (Exception ex) { ViewBag.ErrorMessage = ex.ToString(); BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Lookups, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString()); return(Json(new { ID = result, Message = "An error occured while updating DB." })); } }
private DOCMN_LookupMaster PGetLookupMaster(long?lookupMasterID, long lookupTypeID) { DOCMN_LookupMaster objDOCMN_LookupMaster = new DOCMN_LookupMaster(); try { if (lookupMasterID > 0) { CacheUtility.ClearCache(ConstantTexts.LookupMasterCacheKey); objDOCMN_LookupMaster = CacheUtility.GetLookupById(lookupMasterID); } objDOCMN_LookupMaster.CMN_LookupTypeRef = lookupTypeID; return(objDOCMN_LookupMaster); } catch (Exception ex) { BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.LookupsCorrelation, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString()); throw ex; } }
public ExceptionTypes SaveLookupMaster(DOCMN_LookupMaster objDOCMN_LookupMaster, out string errorMessage) { _retValue = new ExceptionTypes(); return(_retValue = _objDALLookup.SaveLookupMaster(objDOCMN_LookupMaster, out errorMessage)); }
public ExceptionTypes SaveLookupMaster(DOCMN_LookupMaster objDOCMN_LookupMaster, out string errorMessage) { _lstParameters = new List <SqlParameter>(); SqlParameter sqlParam; long lErrocode = 0; long lErrorNumber = 0; errorMessage = string.Empty; long lRowsEffected = 0; try { if (objDOCMN_LookupMaster.CMN_LookupMasterId > 0) { sqlParam = new SqlParameter(); sqlParam.ParameterName = "@CMN_LookupMasterId"; sqlParam.SqlDbType = SqlDbType.BigInt; sqlParam.Value = objDOCMN_LookupMaster.CMN_LookupMasterId; _lstParameters.Add(sqlParam); } sqlParam = new SqlParameter(); sqlParam.ParameterName = "@CMN_LookupTypeRef"; sqlParam.SqlDbType = SqlDbType.BigInt; sqlParam.Value = objDOCMN_LookupMaster.CMN_LookupTypeRef; _lstParameters.Add(sqlParam); sqlParam = new SqlParameter(); sqlParam.ParameterName = "@LookupValue"; sqlParam.SqlDbType = SqlDbType.VarChar; sqlParam.Value = objDOCMN_LookupMaster.LookupValue; _lstParameters.Add(sqlParam); sqlParam = new SqlParameter(); sqlParam.ParameterName = "@LookupDescription"; sqlParam.SqlDbType = SqlDbType.VarChar; sqlParam.Value = objDOCMN_LookupMaster.LookupDescription; _lstParameters.Add(sqlParam); sqlParam = new SqlParameter(); sqlParam.ParameterName = "@DisplayOrder"; sqlParam.SqlDbType = SqlDbType.BigInt; sqlParam.Value = objDOCMN_LookupMaster.DisplayOrder; _lstParameters.Add(sqlParam); sqlParam = new SqlParameter(); sqlParam.ParameterName = "@LoginUserId"; sqlParam.SqlDbType = SqlDbType.Bit; sqlParam.Value = (objDOCMN_LookupMaster.CMN_LookupMasterId > 0) ? objDOCMN_LookupMaster.LastUpdatedByRef : objDOCMN_LookupMaster.CreatedByRef; _lstParameters.Add(sqlParam); sqlParam = new SqlParameter(); sqlParam.ParameterName = "@IsActive"; sqlParam.SqlDbType = SqlDbType.Bit; sqlParam.Value = objDOCMN_LookupMaster.IsActive; _lstParameters.Add(sqlParam); sqlParam = new SqlParameter(); sqlParam.ParameterName = "@ErrorMessage"; sqlParam.SqlDbType = SqlDbType.VarChar; sqlParam.Value = string.Empty; sqlParam.Direction = ParameterDirection.Output; sqlParam.Size = 2000; _lstParameters.Add(sqlParam); long executionResult = _daHelper.ExecuteDMLSP(ConstantTexts.SP_APP_INS_UPD_LookupMaster, _lstParameters.ToArray(), out lErrocode, out lErrorNumber, out lRowsEffected, out errorMessage); sqlParam = _lstParameters.FirstOrDefault(x => x.ParameterName == "@ErrorMessage"); if (sqlParam != null && sqlParam.Value != null) { errorMessage += sqlParam.Value.ToString(); } if (executionResult == (long)ExceptionTypes.Success && string.IsNullOrEmpty(errorMessage)) { return(ExceptionTypes.Success); } else { return(ExceptionTypes.UnknownError); } } catch (Exception ex) { errorMessage = ex.Message; return(ExceptionTypes.UnknownError); } finally { _lstParameters = null; } }