public ActionResult Create(String CityId) { PaperAllocationDistributorDTO objPA = new PaperAllocationDistributorDTO(); objPA.ListState = BindListState(); objPA.ListDistributor = BindListDistributor(); objPA.ListPaper = BindListPaper(CityId); objPA.ListCity = BindListCity(); ViewData["SelectedState"] = string.Empty; ViewData["SelectedPaper"] = string.Empty; ViewData["SelectedCity"] = string.Empty; return(View(objPA)); }
public ActionResult Create(PaperAllocationDistributorDTO obj, FormCollection frm, String CityId) { try { if (string.IsNullOrEmpty(Convert.ToString(obj.DistributorId))) { ModelState.AddModelError("Error", "Please Select Distributor"); } else if (string.IsNullOrEmpty(Convert.ToString(obj.PaperId))) { ModelState.AddModelError("Error", "Please Select Paper Name"); } else if (string.IsNullOrEmpty(Convert.ToString(obj.CityId))) { ModelState.AddModelError("Error", "Please Select City"); } else { obj.PaperAllocateId = 0; obj.CreatedBy = Convert.ToInt32(Session["UserID"]); DateTime timeUtc = System.DateTime.UtcNow; TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone); obj.CreatedDate = cstTime; objPaperAllocationDist.InsertPaperAllocationDistributor(obj); TempData["MessageRegistration"] = "Data Saved Successfully!"; return(RedirectToAction("Create")); } obj.ListDistributor = BindListDistributor(); obj.ListPaper = BindListPaper(CityId); obj.ListCity = BindListCity(); ViewData["SelectedDistributor"] = obj.DistributorId; ViewData["SelectedPaper"] = obj.PaperId; ViewData["SelectedCity"] = obj.CityId; return(View(obj)); } catch (Exception) { throw; } }
public void InsertPaperAllocationDistributor(PaperAllocationDistributorDTO PAllocation) { con.Open(); var para = new DynamicParameters(); para.Add("@PaperAllocateId", PAllocation.PaperAllocateId); // Normal Parameters para.Add("@PaperId", PAllocation.PaperId); para.Add("@CityId", PAllocation.CityId); para.Add("@DistributorId", PAllocation.DistributorId); para.Add("@CreatedDate", PAllocation.CreatedDate); para.Add("@CreatedBy", PAllocation.CreatedBy); para.Add("@ModifiedDate", PAllocation.ModifiedDate); para.Add("@ModifiedBy", PAllocation.ModifiedBy); para.Add("@DeleteStatus", "ACTIVE"); var value = con.Query <int>("SP_Insert_PaperAllocateDistributorMaster", para, null, true, 0, CommandType.StoredProcedure); con.Close(); }