public List <Part_VM> GetPartDDL(Part_VM Model) { var query = new List <Part_VM>(); try { using (var db = new DBConnection()) { var ds = new DataSet(); ds = db.ExecuteDataSet("GetPartDDL", new SqlParameter[] { new SqlParameter("@p_PartName", GetDBNULLString(Model.PartName)) }); query = ConvertToList <Part_VM>(ds.Tables[0]); } } catch (Exception ex) { logger.Error("PartRepository_GetDataDDL Error: ", ex); throw; } return(query); }
public JsonResult AddUpdateData(Part_VM Model) { if (ModelState.IsValid) { try { GetUserInfo(Model); if (Model.PartID == 0 || Model.PartID == null) { var data = _PartRepo.Add(Model); return(GetAddEditDeleteResponse(data, "Add")); } else if (Model.PartID > 0) { var data = _PartRepo.Update(Model); return(GetAddEditDeleteResponse(data, "Update")); } } catch (Exception ex) { logger.Error("PartController_AddUpdateData Error: ", ex); return(GetAddEditErrorException(ex)); } } return(GetModelStateIsValidException(ViewData)); }
public int Delete(Part_VM Model) { int result = 0; try { using (var db = new DBConnection()) { result = db.ExecuteNonQueryRollBack("DeletePart", new SqlParameter[] { new SqlParameter("@p_PartID", GetDBNULL(Model.PartID)), new SqlParameter("@p_EndUserID", GetDBNULL(Model.CurrentEndUserID)), new SqlParameter("@p_UserRoleID", GetDBNULL(Model.CurrentUserRoleID)), new SqlParameter("@p_ScreenID", GetDBNULL(Model.CurrentScreenID)), new SqlParameter("@p_AccessPoint", GetDBNULLString(Model.AccessPoint)) }); } } catch (Exception ex) { logger.Error("PartRepository_Delete Error: ", ex); throw; } return(result); }
public List <Part_VM> GetData(Part_VM Model) { var query = new List <Part_VM>(); try { using (var db = new DBConnection()) { var ds = new DataSet(); ds = db.ExecuteDataSet("GetPart", new SqlParameter[] { new SqlParameter("@p_PartID", GetDBNULL(Model.PartID)), new SqlParameter("@p_PartName", GetDBNULLString(Model.PartName)), new SqlParameter("@p_PartDescription", GetDBNULLString(Model.PartDescription)), new SqlParameter("@p_PartVendor", GetDBNULLString(Model.PartVendor)), new SqlParameter("@p_PartCost", GetDBNULL(Model.PartCost)), new SqlParameter("@p_PartQuantity", GetDBNULL(Model.PartQuantity)) }); query = ConvertToList <Part_VM>(ds.Tables[0]); } } catch (Exception ex) { logger.Error("PartRepository_GetData Error: ", ex); throw; } return(query); }
public IEnumerable <SelectListItem> GetPart(Part_VM Model) { IEnumerable <Part_VM> query = new PartRepository().GetData(Model); IEnumerable <SelectListItem> list = query.Select(x => new SelectListItem() { Text = x.PartName, Value = x.PartID.ToString() }).ToList(); return(list);//.OrderBy(x => x.Text); }
public JsonResult GetData(Part_VM Model) { try { List <Part_VM> vm = _PartRepo.GetData(Model); return(GetDataResponse(vm)); } catch (Exception ex) { return(GetDataResponseException(ex)); } }
public JsonResult Delete(Part_VM Model) { if (CheckAccess(Model.CurrentScreenID, "Part")) { try { GetUserInfo(Model); if (Model.PartID > 0 && Model.PartID != null) { var data = _PartRepo.Delete(Model); return(GetAddEditDeleteResponse(data, "Delete")); } } catch (Exception ex) { logger.Error("PartController_Delete Error: ", ex); return(GetAddEditErrorException(ex)); } } return(GetModelStateIsValidException(ViewData)); }
public int Add(Part_VM Model) { int result = 0; try { using (var db = new DBConnection()) { var output = new SqlParameter("@p_PartID", 0) { Direction = ParameterDirection.Output }; result = db.ExecuteNonQueryRollBack("AddPart", new SqlParameter[] { new SqlParameter("@p_PartName", GetDBNULLString(Model.PartName)), new SqlParameter("@p_PartDescription", GetDBNULLString(Model.PartDescription)), new SqlParameter("@p_PartVendor", GetDBNULLString(Model.PartVendor)), new SqlParameter("@p_PartCost", GetDBNULL(Model.PartCost)), new SqlParameter("@p_PartQuantity", GetDBNULL(Model.PartQuantity)), new SqlParameter("@p_EndUserID", GetDBNULL(Model.CurrentEndUserID)), new SqlParameter("@p_UserRoleID", GetDBNULL(Model.CurrentUserRoleID)), new SqlParameter("@p_ScreenID", GetDBNULL(Model.CurrentScreenID)), new SqlParameter("@p_AccessPoint", GetDBNULLString(Model.AccessPoint)), output }); result = Convert.ToInt32(output.Value); } } catch (Exception ex) { logger.Error("PartRepository_Add Error: ", ex); throw; } return(result); }