public ActionResult AddSparePartName(ManageSparePart model) { try { if (model.PartImage1 != null) { model.Part_Image = SaveImageFile(model.PartImage1); } using (var con = new SqlConnection(_connectionString)) { var result = con.Query <int>("Add_Edit_Delete_SparePart", new { model.PartId, model.CategoryId, model.SubCategory, model.SpareTypeId, model.BrandId, model.PartName, model.ProductId, model.TUPC, model.TGFGCode, model.SpareCode, model.CTHNo, model.Part_Image, model.IsActive, model.SortOrder, User = CurrentUser.UserId, CurrentUser.CompanyId, Action = "add" }, commandType: CommandType.StoredProcedure).FirstOrDefault(); var response = new ResponseModel(); if (result == 1) { response.IsSuccess = true; response.Response = "Successfully Added"; TempData["response"] = response; } else { response.IsSuccess = false; response.Response = "Spare Part Name Already Exist"; TempData["response"] = response; } } } catch (Exception e) { throw e; } return(RedirectToAction("ManageSparePartName")); }
public ActionResult AddSparePartName() { var sparepart = new ManageSparePart(); sparepart.CTHNoList = new SelectList(dropdown.BindGstHsnCode(), "Value", "Text"); sparepart.CategoryList = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"); sparepart.BrandList = new SelectList(dropdown.BindBrand(CurrentUser.CompanyId), "Value", "Text"); sparepart.DeviceModelNameList = new SelectList(dropdown.BindProduct(sparepart.BrandId), "Value", "Text"); sparepart.SpareTypeIdList = new SelectList(dropdown.BindSpareType(CurrentUser.CompanyId), "Value", "Text"); sparepart.SubCategoryList = new SelectList(dropdown.BindSubCategory(sparepart.CategoryId), "Value", "Text"); return(PartialView(sparepart)); }
public ActionResult ManageSparePartName() { ManageSparePart msp = new ManageSparePart { SubCategoryList = new SelectList(Enumerable.Empty <SelectListItem>()), CategoryList = new SelectList(Enumerable.Empty <SelectListItem>()), BrandList = new SelectList(Enumerable.Empty <SelectListItem>()), DeviceModelNameList = new SelectList(Enumerable.Empty <SelectListItem>()), CTHNoList = new SelectList(Enumerable.Empty <SelectListItem>()) }; if (TempData["AddSpareName"] != null) { ViewBag.AddSpareName = TempData["AddSpareName"].ToString(); } if (TempData["EditSpareName"] != null) { ViewBag.EditSpareName = TempData["EditSpareName"].ToString(); } return(View()); }
public ActionResult EditSpareName(int SpareTypeId) { ManageSparePart msp = new ManageSparePart(); if (SpareTypeId == 0) { msp.SubCategoryList = new SelectList(Enumerable.Empty <SelectListItem>()); msp.CategoryList = new SelectList(Enumerable.Empty <SelectListItem>()); msp.BrandList = new SelectList(Enumerable.Empty <SelectListItem>()); msp.DeviceModelNameList = new SelectList(Enumerable.Empty <SelectListItem>()); msp.SpareTypeIdList = new SelectList(Enumerable.Empty <SelectListItem>()); } else { //ViewBag.CTHNo = new SelectList(dropdown.BindGstHsnCode(), "Value", "Text"); using (var con = new SqlConnection(_connectionString)) { var result = con.Query <ManageSparePart>("Select * from MstSparePart where SpareTypeId=@SpareTypeId", new { SpareTypeId = SpareTypeId }, commandType: CommandType.Text).FirstOrDefault(); result.SubCategoryList = new SelectList(dropdown.BindSubCategory(), "Value", "Text"); result.CategoryList = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"); result.BrandList = new SelectList(dropdown.BindBrand(CurrentUser.CompanyId), "Value", "Text"); result.DeviceModelNameList = new SelectList(dropdown.BindProduct(CurrentUser.CompanyId), "Value", "Text"); result.SpareTypeIdList = new SelectList(dropdown.BindSpareType(CurrentUser.CompanyId), "Value", "Text"); result.CTHNoList = new SelectList(dropdown.BindGstHsnCode(), "Value", "Text"); if (result != null) { result.Brand = result.BrandId.ToString(); result.Category = result.CategoryId.ToString(); result.DeviceModelName = result.ProductId.ToString(); } return(PartialView("EditSpareName", result)); } } return(View()); }