/// <summary> /// Get the Locations /// </summary> /// <param name="locationCode">Code of the Location </param> /// <returns>Returns All location if location code is not specified. otherwise return only specified location</returns> public List <DDLOC_MAST> GetLocationDetails(DDLOC_MAST paramEntity = null) { List <DDLOC_MAST> lstResult = null; try { if (!DB.IsNotNullOrEmpty()) { return(lstResult); } if (paramEntity.IsNotNullOrEmpty()) { lstResult = (from row in DB.DDLOC_MAST where (Convert.ToBoolean(Convert.ToInt16(row.DELETE_FLAG)) == false || row.DELETE_FLAG == null) && row.LOC_CODE == paramEntity.LOC_CODE orderby row.LOCATION ascending select row).ToList <DDLOC_MAST>(); } else { lstResult = (from row in DB.DDLOC_MAST where (Convert.ToBoolean(Convert.ToInt16(row.DELETE_FLAG)) == false || row.DELETE_FLAG == null) orderby row.LOCATION ascending select row).ToList <DDLOC_MAST>(); } } catch (Exception ex) { throw ex.LogException(); } return(lstResult); }
/// <summary> /// Get the Locations /// </summary> /// <param name="locationCode">Code of the Location </param> /// <returns>Returns All location if location code is not specified. otherwise return only specified location</returns> public List <DDLOC_MAST> GetLocationsByCode(DDLOC_MAST locationEntity = null) { List <DDLOC_MAST> lstLocations = null; try { if (!DB.IsNotNullOrEmpty()) { return(lstLocations); } if (locationEntity.IsNotNullOrEmpty() && locationEntity.LOC_CODE.IsNotNullOrEmpty()) { lstLocations = (from row in DB.DDLOC_MAST where Convert.ToBoolean(Convert.ToInt16(row.DELETE_FLAG)) == false && row.LOC_CODE == locationEntity.LOC_CODE select row).ToList <DDLOC_MAST>(); } else { lstLocations = (from row in DB.DDLOC_MAST where Convert.ToBoolean(Convert.ToInt16(row.DELETE_FLAG)) == false select row).ToList <DDLOC_MAST>(); } } catch (Exception ex) { throw ex.LogException(); } return(lstLocations); }
public bool DeleteLocationCode(string operCode, string nextAction, ref string message) { DDLOC_MAST ddLocMaster = (from c in DB.DDLOC_MAST where c.LOC_CODE == operCode // && ((Convert.ToBoolean(Convert.ToInt16(c.DELETE_FLAG)) == false) || (c.DELETE_FLAG == null)) select c).SingleOrDefault <DDLOC_MAST>(); try { if (nextAction == "DELETE") { if (ddLocMaster != null) { if (ddLocMaster.DELETE_FLAG == true) { ddLocMaster.DELETE_FLAG = false; } else { ddLocMaster.DELETE_FLAG = true; } //ddLocMaster.DELETE_FLAG = true; ddLocMaster.UPDATED_DATE = DateTime.Now; ddLocMaster.UPDATED_BY = userInformation.UserName; // DB.DDLOC_MAST.DeleteOnSubmit(ddLocMaster); DB.SubmitChanges(); message = PDMsg.DeletedSuccessfully; } else if (ddLocMaster == null) { message = PDMsg.NoRecordFound; } } } catch (Exception ex) { ex.LogException(); DB.DDLOC_MAST.Context.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, ddLocMaster); } return(true); }
public bool AddNewLocationMaster(bool isActive, string operCode, string operDesc, string nextAction, ref string message) { bool _status = false; DDLOC_MAST ddLocMaster = (from c in DB.DDLOC_MAST // where c.LOC_CODE == operCode where (c.LOC_CODE == operCode && operDesc.ToUpper() == operDesc.ToUpper()) // && ((Convert.ToBoolean(Convert.ToInt16(c.DELETE_FLAG)) == false) || (c.DELETE_FLAG == null)) select c).FirstOrDefault <DDLOC_MAST>(); try { if (nextAction == "ADD") { if (ddLocMaster == null) { ddLocMaster = new DDLOC_MAST(); ddLocMaster.LOC_CODE = (string)operCode; ddLocMaster.LOCATION = (string)operDesc; ddLocMaster.DELETE_FLAG = isActive; ddLocMaster.ENTERED_DATE = DateTime.Now; ddLocMaster.ENTERED_BY = userInformation.UserName; ddLocMaster.ROWID = Guid.NewGuid(); DB.DDLOC_MAST.InsertOnSubmit(ddLocMaster); DB.SubmitChanges(); message = PDMsg.SavedSuccessfully; //"Records Added sucessfully"; } else { //if (ddLocMaster.DELETE_FLAG != true) //{ // ddLocMaster.LOCATION = (string)operDesc; // ddLocMaster.UPDATED_DATE = DateTime.Now; // ddLocMaster.DELETE_FLAG = isActive; // ddLocMaster.UPDATED_BY = userInformation.UserName; // DB.SubmitChanges(); // message = PDMsg.SavedSuccessfully; //} //else //{ DDLOC_MAST ddLocMaster1 = (from c in DB.DDLOC_MAST where c.LOC_CODE == operCode // where (c.LOC_CODE == operCode || operDesc.ToUpper().Replace(" ", "") == c.LOCATION.ToUpper().Replace(" ", "")) // && ((Convert.ToBoolean(Convert.ToInt16(c.DELETE_FLAG)) == false) || (c.DELETE_FLAG == null)) select c).FirstOrDefault <DDLOC_MAST>(); if (ddLocMaster1 != null) { message = PDMsg.AlreadyExists("Location Code"); return(false); } //else //{ // message = PDMsg.AlreadyExists("Location Desc"); // return false; //} } } else if (nextAction == "EDIT") { DDLOC_MAST ddLocMaster1 = (from c in DB.DDLOC_MAST where c.LOC_CODE != operCode && c.LOCATION == operDesc select c).FirstOrDefault <DDLOC_MAST>(); //if (ddLocMaster1 != null) //{ // message = PDMsg.AlreadyExists("Location Desc"); // return false; //} ddLocMaster.LOCATION = (string)operDesc; ddLocMaster.UPDATED_DATE = DateTime.Now; ddLocMaster.DELETE_FLAG = isActive; ddLocMaster.UPDATED_BY = userInformation.UserName; DB.SubmitChanges(); message = PDMsg.UpdatedSuccessfully; } _status = true; } catch (Exception ex) { ex.LogException(); if (nextAction == "ADD") { DB.DDLOC_MAST.DeleteOnSubmit(ddLocMaster); } else if (nextAction == "EDIT") { DB.DDLOC_MAST.Context.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, ddLocMaster); } } return(_status); }