public ActionResult ComConsignment(int id) { tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id); int distance = Convert.ToInt32(con.Distance); var tblPricelist = from ob in dc.tblPriceLists where ob.UnitName == con.UnitType || ob.UnitName == "KM" select ob; double AvgDistancePrice = (from ob in tblPricelist where ob.UnitName == "KM" && ob.MinValue <= distance && ob.MaxValue >= distance select ob).Average(ob => ob.PricePerUnit); double AvgUnitPrice = (from ob in tblPricelist where ob.UnitName == con.UnitType select ob).Average(ob => ob.PricePerUnit); double MaxDistancePrice = AvgDistancePrice * Convert.ToInt32(con.Distance); double MaxUnitPrice = AvgUnitPrice * Convert.ToInt32(con.UnitValue); double CalculatedValue = MaxDistancePrice + MaxUnitPrice; ViewBag.Budgets = CalculatedValue; ViewBag.User = (from ob in dc.tblUsers where ob.UserId == con.UserId select ob).Take(1).SingleOrDefault().FirstName; ViewBag.House = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().HouseNo; ViewBag.Landmark = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().Landmark; ViewBag.Area = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().Area; ViewBag.Source = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().Address; ViewBag.City = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().CityId.ToString(); ViewBag.Destination = (from ob in dc.tblAddresses where ob.AddressId == con.DestinationId select ob).Take(1).SingleOrDefault().Address; ViewBag.ConsignmentImage = from ob in dc.tblConSignmentImages where ob.ConsignmentID == id select ob; ViewBag.Budget = (from ob in dc.tblConsignments where ob.ConsignmentId == con.ConsignmentId select ob).Take(1).SingleOrDefault().Budget; ViewBag.MinTime = (from ob in dc.tblConsignments where ob.ConsignmentId == con.ConsignmentId select ob).Take(1).SingleOrDefault().MinTime; ViewBag.MaxTime = (from ob in dc.tblConsignments where ob.ConsignmentId == con.ConsignmentId select ob).Take(1).SingleOrDefault().MaxTime; return(View(con)); }
public ActionResult ViewBill(int id) { tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id); ViewBag.UserName = (from ob in dc.tblUsers where ob.UserId == con.UserId select ob).Take(1).SingleOrDefault().FirstName; string Name = ViewBag.UserName; tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.ConsignmentId == con.ConsignmentId); tblBidding bid = dc.tblBiddings.SingleOrDefault(ob => ob.BidId == book.BidId); ViewBag.Company = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().CompanyName; ViewBag.Weburl = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().WebURL; ViewBag.Contact = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().ContactPersonNo; ViewBag.Desc = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().Desc; ViewBag.Price = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().Price; ViewBag.Tolltax = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().TollTax; ViewBag.GST = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().GST; ViewBag.TotalPrice = (from ob in dc.tblBills where ob.BookingId == book.BookingId select ob).Take(1).SingleOrDefault().TotalPrice; string Company = ViewBag.Company; string weburl = ViewBag.Weburl; string cno = ViewBag.Contact; return(View(con)); }
public ActionResult bill(FormCollection form, int id) { tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.BookingId == id); tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == book.ConsignmentId); tblUser user = dc.tblUsers.SingleOrDefault(ob => ob.UserId == con.UserId); tblBidding bid = dc.tblBiddings.SingleOrDefault(ob => ob.BidId == book.BidId); ViewBag.UserName = (from ob in dc.tblUsers where ob.UserId == con.UserId select ob).Take(1).SingleOrDefault().FirstName; ViewBag.Company = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().CompanyName; ViewBag.Weburl = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().WebURL; ViewBag.Contact = (from ob in dc.tblTransportCompanies where ob.CompanyId == bid.CompanyId select ob).Take(1).SingleOrDefault().ContactPersonNo; var com = Convert.ToInt32(Session["CompanyId"]); tblTransportCompany company = dc.tblTransportCompanies.SingleOrDefault(ob => ob.CompanyId == com); //ViewBag.Bill = (from ob in dc.tblBookings where ob.BookingId == id select ob).Take(1).SingleOrDefault().TotalPayment; tblBill bill = new tblBill(); bill.BookingId = id; bill.UserId = Convert.ToInt32(user.UserId); bill.Desc = form["txtDesc"]; bill.Price = Convert.ToInt32(book.TotalPayment); bill.TollTax = Convert.ToInt32(form["txtToll"]); bill.GST = (Convert.ToInt32(book.TotalPayment) * 18) / 100; bill.TotalPrice = Convert.ToInt32(book.TotalPayment) + Convert.ToInt32(form["txtToll"]) + (Convert.ToInt32(book.TotalPayment) * 18) / 100; bill.CompanyId = Convert.ToInt32(Session["CompanyId"]); bill.CreatedOn = DateTime.Now; dc.tblBills.Add(bill); dc.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult EditBook(FormCollection form, int id) { tblBooking book = dc.tblBookings.SingleOrDefault(ob => ob.ConsignmentId == id); book.VehicleId = Convert.ToInt32(form["ddVehicle"]); book.DriverId = Convert.ToInt32(form["ddDriver"]); book.DispatchDate = Convert.ToDateTime(form["txtDispatch"]); book.DeliveredDate = Convert.ToDateTime(form["txtDeliver"]); book.TotalPayment = Convert.ToInt32(form["txtPayment"]); book.PaymentMode = form["txtPaymentMode"]; book.Remarks = form["txtRemark"]; Session["Price"] = book.TotalPayment; dc.SaveChanges(); tblBidding bidding = dc.tblBiddings.SingleOrDefault(ob => ob.BidId == book.BidId); bidding.IsAssigned = true; dc.SaveChanges(); tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id); con.IsProcessed = true; dc.SaveChanges(); return(RedirectToAction("bill", "ClientCompany", new { id = book.BookingId })); }
public ActionResult Insert(FormCollection form, HttpPostedFileBase[] txtFile) { tblConsignment con = new tblConsignment(); con.DispatchDate = Convert.ToDateTime(form["txtDate"]); //con.ProfilePic = name.ToString(); con.UnitType = form["unittype"]; con.UnitValue = Convert.ToInt32(form["txtValue"]); con.UserId = Convert.ToInt32(Session["LogID"]); string val = form["chkflame"]; if (form["chkflame"] == "on") { con.IsFlamable = true; } if (form["chkdelicate"] == "on") { con.IsDelicate = true; } if (form["chkrefregerated"] == "on") { con.IsRefregreted = true; } con.Distance = form["txtDistance"]; dc.tblConsignments.Add(con); dc.SaveChanges(); int LastID = (from ob in dc.tblConsignments orderby ob.ConsignmentId descending select ob).Take(1).SingleOrDefault().ConsignmentId; Session["LastID"] = LastID; string name = "txtFile"; if (txtFile != null) { foreach (HttpPostedFileBase file in txtFile) { int size = (int)file.ContentLength / 1024; var extention = System.IO.Path.GetExtension(file.FileName); if (size <= 1024 && (extention.ToLower().Equals(".jpg") || extention.ToLower().Equals(".jpeg") || extention.ToLower().Equals(".png"))) { name = code() + "" + extention; string path = Server.MapPath("~/Images/"); file.SaveAs(path + "" + name); tblConSignmentImage img = new tblConSignmentImage(); img.ConsignmentID = LastID; img.ImageURL = name; img.IsActive = true; dc.tblConSignmentImages.Add(img); } } dc.SaveChanges(); } return(RedirectToAction("Insert2", "ClientConsignment")); }
public ActionResult Detail(int id) { tblConsignment consignment = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id); ViewBag.User = (from ob in dc.tblUsers where ob.UserId == consignment.UserId select ob).Take(1).SingleOrDefault().FirstName; ViewBag.Source = (from ob in dc.tblAddresses where ob.AddressId == consignment.SourceId select ob).Take(1).SingleOrDefault().Address; ViewBag.Destination = (from ob in dc.tblAddresses where ob.AddressId == consignment.DestinationId select ob).Take(1).SingleOrDefault().Address; string Name = ViewBag.User; string source = ViewBag.Source; string destination = ViewBag.Destination; ViewBag.ConsignmentImage = from ob in dc.tblConSignmentImages where ob.ConsignmentID == id select ob; return(View(consignment)); }
public ActionResult Insert2() { int ConID = Convert.ToInt32(Session["LastID"]); tblConsignment CurrentCon = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == ConID); int distance = Convert.ToInt32(CurrentCon.Distance); var tblPricelist = from ob in dc.tblPriceLists where ob.UnitName == CurrentCon.UnitType || ob.UnitName == "KM" select ob; double AvgDistancePrice = (from ob in tblPricelist where ob.UnitName == "KM" && ob.MinValue <= distance && ob.MaxValue >= distance select ob).Average(ob => ob.PricePerUnit); double AvgUnitPrice = (from ob in tblPricelist where ob.UnitName == CurrentCon.UnitType select ob).Average(ob => ob.PricePerUnit); double MaxDistancePrice = AvgDistancePrice * Convert.ToInt32(CurrentCon.Distance); double MaxUnitPrice = AvgUnitPrice * Convert.ToInt32(CurrentCon.UnitValue); double CalculatedValue = MaxDistancePrice + MaxUnitPrice; ViewBag.Budget = CalculatedValue; return(View()); }
public JsonResult Active(int id) { tblConsignment consignment = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id); if (consignment.IsActive == true) { consignment.IsActive = false; } else { consignment.IsActive = true; } dc.SaveChanges(); return(Json(consignment.IsActive, JsonRequestBehavior.AllowGet)); }
public ActionResult ViewCon(int id) { tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == id); ViewBag.User = (from ob in dc.tblUsers where ob.UserId == con.UserId select ob).Take(1).SingleOrDefault().FirstName; ViewBag.House = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().HouseNo; //ViewBag.house = (from ob in dc.tblAddresses where ob.AddressId == con.DestinationId select ob).Take(1).SingleOrDefault().HouseNo; ViewBag.Landmark = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().Landmark; ViewBag.Area = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().Area; ViewBag.Source = (from ob in dc.tblAddresses where ob.AddressId == con.SourceId select ob).Take(1).SingleOrDefault().Address; ViewBag.City = (from ob in dc.CityMasters where ob.ID == con.SourceId select ob).Take(1).SingleOrDefault().Name; ViewBag.Destination = (from ob in dc.tblAddresses where ob.AddressId == con.DestinationId select ob).Take(1).SingleOrDefault().Address; ViewBag.BidCount = (from ob in dc.tblBiddings where ob.ConsignmentId == con.ConsignmentId select ob).Count(); ViewBag.ConsignmentImage = from ob in dc.tblConSignmentImages where ob.ConsignmentID == id select ob; //ViewBag.assign = from ob in dc.tblBiddings where ob.ConsignmentId == con.ConsignmentId select ob; return(View(con)); }
public ActionResult Insert2(FormCollection form) { int LId = Convert.ToInt32(Session["LastID"]); tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == LId); con.Budget = Convert.ToInt32(form["txtBudget"]); con.MinBidValue = Convert.ToInt32(form["txtminbidvalue"]); con.MaxBidValue = Convert.ToInt32(form["txtmaxbidvalue"]); con.MinTime = form["txtmintime"]; con.MaxTime = form["txtmaxtime"]; con.ReceiverName = form["txtName"]; con.ReceiverContactNo = form["txtCno"]; con.ReceiverPinNo = Convert.ToInt32(form["txtPin"]); con.IsActive = true; con.IsProcessed = false; dc.SaveChanges(); return(RedirectToAction("Insert3", "ClientConsignment")); }
public ActionResult Insert3(FormCollection form) { tblAddress fromplace = new tblAddress(); fromplace.AddressType = form["addtype"]; fromplace.HouseNo = form["txtHouseNo"]; fromplace.Landmark = form["txtLandmark"]; fromplace.Area = form["txtArea"]; fromplace.UserId = Convert.ToInt32(Session["LogID"]); fromplace.Address = form["txtAddress"]; fromplace.CityId = Convert.ToInt32(form["ddCity"]); fromplace.Zipcode = form["txtZip"]; dc.tblAddresses.Add(fromplace); dc.SaveChanges(); int LastFromAddressID = (from ob in dc.tblAddresses orderby ob.AddressId descending select ob).Take(1).SingleOrDefault().AddressId; tblAddress toplace = new tblAddress(); toplace.AddressType = form["addtype"]; toplace.HouseNo = form["txttoHouseNo"]; toplace.Landmark = form["txttoLandmark"]; toplace.Area = form["txttoArea"]; toplace.UserId = Convert.ToInt32(Session["LogID"]); toplace.Address = form["txttoAddress"]; toplace.CityId = Convert.ToInt32(form["ddtoCity"]); toplace.Zipcode = form["txttoZip"]; dc.tblAddresses.Add(toplace); dc.SaveChanges(); int LastToAddressID = (from ob in dc.tblAddresses orderby ob.AddressId descending select ob).Take(1).SingleOrDefault().AddressId; int LastID = Convert.ToInt32(Session["LastID"]); tblConsignment con = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == LastID); con.SourceId = LastFromAddressID; con.DestinationId = LastToAddressID; dc.SaveChanges(); return(RedirectToAction("Index", "Home")); }