public JsonResult GetCylinderAmountByCustomer(int cylinderid, int customerId) { var status = false; decimal amount = 0; if (cylinderid > 0) { try { CylinderMaster c = new CylinderMaster(); c = repo.GetCylinderType().Where(obj => obj.ID == cylinderid).FirstOrDefault(); var customerdetail = db.CustomerCylinderDetails.Where(ite => ite.cylinder_Id == cylinderid && ite.cust_id == customerId).FirstOrDefault(); decimal discount = customerdetail == null ? 0 : Convert.ToDecimal(customerdetail.discount); status = true; amount = c.amount.Value - discount; } catch (Exception) { status = false;; amount = amount; } } return(new JsonResult() { Data = new { status = status, amount = amount } }); }
public JsonResult GetCylinderAmount(int?val) { var status = false; decimal amount = 0; if (val != null) { try { CylinderMaster c = new CylinderMaster(); c = repo.GetCylinderType().Where(obj => obj.ID == val).FirstOrDefault(); status = true; amount = c.amount.Value; } catch (Exception) { status = false;; amount = 0; } } return(new JsonResult() { Data = new { status = status, amount = amount } }); }
public ActionResult GetAmount(int?val) { if (val != null) { CylinderMaster c = new CylinderMaster(); c = repo.GetCylinderType().Where(obj => obj.ID == val).FirstOrDefault(); return(Json(new { Success = "true", Data = new { amount = c.amount, ctype = c.cylinderType } })); } else { return(Json(new { Success = "false" })); } }
public ActionResult Create(CylinderMaster obj) { try { if (ModelState.IsValid) { var cylindertypelist = repo.GetAllCylinders(); int count = cylindertypelist.Where(ite => ite.cylinderType.ToLower() == obj.cylinderType.ToLower()).ToList().Count(); if (count <= 0) { obj.CreatedBy = Convert.ToString(Session["UserName"]); obj.CreatedOn = System.DateTime.Now; repo.Insert(obj); ViewBag.SuccessMsg = "Record Added Successfully"; // var CusotmerMasterlist = repo.GetAllCylinders(); return(RedirectToAction("Listing")); } else { ViewBag.ErrorMsg = "Cylinder Type with same name already exists"; return(View(obj)); } } else { ViewBag.ErrorMsg = "Please fill mandatory fields"; return(View(obj)); } } catch (Exception ex) { ViewBag.ErrorMsg = "Sorry Some Problem Occured"; } return(RedirectToAction("Listing")); }
public ActionResult Edit(DeliveryDetail obj) { try { if (ModelState.IsValid) { var c = new List <CylinderMaster>(); var objCylinderlist = db.CustomerCylinderDetails.Where(a => a.cust_id == obj.cust_id).ToList(); foreach (var t in objCylinderlist) { CylinderMaster temp = db.CylinderMasters.Where(a => a.cylinderType == t.cylinderType).FirstOrDefault(); c.Add(temp); } obj.cylinders = c; obj.users = repo.GetAllUsers(); obj.customers = repo.GetAllCustomers(); var tempTotal = Convert.ToDecimal(TempData["TotalAmount"].ToString()); if (tempTotal != obj.totalAmount) { var gst = Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["gst"]); var total = Convert.ToDecimal(obj.totalAmount) / gst; var diff = Convert.ToDecimal(obj.totalAmount) - total; obj.cgst = diff / 2; obj.sgst = diff / 2; } repo.Update(obj); ViewBag.SuccessMsg = "Record Updated Successfully"; } } catch (Exception ex) { ViewBag.ErrorMsg = "Sorry Some Problem Occured"; } var DeliveryDetaillist = repo.GetAllDeliveryDetails(); return(View("Listing", DeliveryDetaillist)); }
public ActionResult Edit(int id) { try { var DeliveryDetails = repo.GetDeliveryDetailByID(id); var c = new List <CylinderMaster>(); var objCylinderlist = db.CustomerCylinderDetails.Where(a => a.cust_id == DeliveryDetails.cust_id).ToList(); foreach (var t in objCylinderlist) { CylinderMaster temp = db.CylinderMasters.Where(a => a.cylinderType == t.cylinderType).FirstOrDefault(); c.Add(temp); } DeliveryDetails.cylinders = c; DeliveryDetails.users = repo.GetAllUsers(); DeliveryDetails.customers = repo.GetAllCustomers(); TempData["TotalAmount"] = DeliveryDetails.totalAmount; return(View(DeliveryDetails)); } catch (Exception) { ViewBag.ErrorMsg = "Sorry Some Problem Occured"; } return(RedirectToAction("Listing")); }