コード例 #1
0
        public ActionResult EditSpareType(int SpareTypeId)
        {
            ManageSpareType mst = new ManageSpareType();

            if (SpareTypeId == 0)
            {
                mst.SubCategoryList = new SelectList(Enumerable.Empty <SelectListItem>());
                mst.CategoryList    = new SelectList(Enumerable.Empty <SelectListItem>());
            }
            else
            {
                using (var con = new SqlConnection(_connectionString))
                {
                    var result = con.Query <ManageSpareType>("Select * from MstSpareType where SpareTypeId=@SpareTypeId", new { SpareTypeId = SpareTypeId },
                                                             commandType: CommandType.Text).FirstOrDefault();
                    result.CategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text");
                    result.SubCategoryList = new SelectList(dropdown.BindSubCategory(), "Value", "Text");
                    //testing
                    //ViewBag.SubCategory = new SelectList(dropdown.BindSubCategory(result.CategoryId), "Value", "Text");
                    if (result != null)
                    {
                        result.Category    = result.CategoryId.ToString();
                        result.SubCategory = Convert.ToString(result.SubCategoryId);
                    }
                    return(PartialView("EditSpareType", result));
                }
            }

            return(View());
        }
コード例 #2
0
        public ActionResult AddSpareType()
        {
            //using (var con = new SqlConnection(_connectionString))
            //{
            //    var result = con.Query<int>("select coalesce(MAX(SortOrder),0) from MstSpareType", null, commandType: CommandType.Text).FirstOrDefault();
            //    ViewBag.SortOrder = result + 1;
            //}

            var sparetype = new ManageSpareType {
                CategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"),
                SubCategoryList = new SelectList(Enumerable.Empty <SelectListItem>())
            };

            return(PartialView(sparetype));
        }
コード例 #3
0
        public ActionResult SpareIndex()
        {
            ManageSpareType mst = new ManageSpareType();

            mst.CategoryList    = new SelectList(Enumerable.Empty <SelectListItem>());
            mst.SubCategoryList = new SelectList(Enumerable.Empty <SelectListItem>());
            if (TempData["AddSparePart"] != null)
            {
                ViewBag.AddSparePart = TempData["AddSparePart"].ToString();
            }

            if (TempData["EditSparePart"] != null)
            {
                ViewBag.EditSparePart = TempData["EditSparePart"].ToString();
            }

            return(View());
        }
コード例 #4
0
        public ActionResult EditSpareType(ManageSpareType model)
        {
            try
            {
                using (var con = new SqlConnection(_connectionString))
                {
                    var result = con.Query <int>("Add_Edit_Delete_SpareType",
                                                 new
                    {
                        model.SpareTypeId,
                        model.SpareTypeName,
                        model.CategoryId,
                        model.SubCategoryId,
                        model.SortOrder,
                        model.IsActive,
                        User   = CurrentUser.UserId,
                        Action = "edit",
                        CurrentUser.CompanyId
                    }, commandType: CommandType.StoredProcedure).FirstOrDefault();
                    var response = new ResponseModel();
                    if (result == 2)
                    {
                        response.IsSuccess = true;
                        response.Response  = "Updated Successfully";
                    }
                    else
                    {
                        response.IsSuccess = false;
                        response.Response  = "Allready Exits";
                    }
                    TempData["response"] = response;
                    TempData.Keep("response");
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(RedirectToAction("SpareIndex"));
        }