public ActionResult Create() { int depotid = Convert.ToInt32(Session["CurrentDepotID"].ToString()); int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString()); int userId = Convert.ToInt32(Session["UserID"].ToString()); ViewBag.depot = db.tblDepots.ToList(); //ViewBag.depot = (from c in db.tblDepots where c.ID == depotid select c).ToList(); ViewBag.employee = db.EmployeeMasters.ToList(); ViewBag.employeerec = db.EmployeeMasters.ToList(); ViewBag.Customer = db.CustomerMasters.ToList(); ViewBag.Movement = db.CourierMovements.ToList(); ViewBag.Employee = db.EmployeeMasters.ToList(); ViewBag.FAgent = db.ForwardingAgentMasters.ToList(); ViewBag.Movement = db.CourierMovements.ToList(); ViewBag.ProductType = db.ProductTypes.ToList(); ViewBag.parceltype = db.ParcelTypes.ToList(); ViewBag.customerrate = db.CustomerRates.ToList(); ViewBag.TypeofGoods = db.TypeOfGoods.ToList(); ViewBag.CourierDescription = db.CourierDescriptions.ToList(); InScanMasterVM obj = new InScanMasterVM(); PickupRequestDAO _dao = new PickupRequestDAO(); string AWBNo = _dao.GetMaAWBNo(branchid); obj.AWBNo = AWBNo; obj.BranchID = branchid; obj.DepotID = depotid; obj.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); obj.DeviceID = "WebSite"; int pickedupid = (from e in db.EmployeeMasters where e.UserID == userId select e.EmployeeID).First(); obj.TransactionDate = DateTime.Now; return(View(obj)); }
public ActionResult Create(PickupRequestVM v) { PickupRequestDAO _dao = new PickupRequestDAO(); int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString()); int depotId = Convert.ToInt32(Session["CurrentDepotID"].ToString()); int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); int uid = Convert.ToInt32(Session["UserID"].ToString()); UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault(); int empid = u.UserID; string empname = u.UserName; InScanMaster _enquiry = new InScanMaster(); if (v.InScanID == 0) { int id = (from c in db.InScanMasters orderby c.InScanID descending select c.InScanID).FirstOrDefault(); _enquiry.InScanID = id + 1; _enquiry.EnquiryNo = _dao.GetMaxPickupRequest(companyId, branchid); // (id + 1).ToString(); _enquiry.ConsignmentNo = _dao.GetMaAWBNo(companyId, branchid); _enquiry.AcCompanyID = companyId; _enquiry.BranchID = branchid; _enquiry.DepotID = depotId; _enquiry.TransactionDate = DateTime.Now; _enquiry.DeviceID = "WebSite"; _enquiry.IsDeleted = false; int statustypeid = db.tblStatusTypes.Where(c => c.Name == "PICKUP REQUEST").FirstOrDefault().ID; _enquiry.StatusTypeId = statustypeid; //pickuprequest } else { _enquiry = db.InScanMasters.Find(v.InScanID); } _enquiry.DocumentSetupID = v.DocumentTypeId; _enquiry.PickupRequestDate = Convert.ToDateTime(v.EnquiryDate); _enquiry.CustomerID = v.CustomerID; _enquiry.ConsignorCountryName = v.ConsignorCountryName; _enquiry.ConsignorCityName = v.ConsignorCityName; _enquiry.ConsigneeLocationName = v.ConsigneeLocationName; _enquiry.ConsignorLocationName = v.ConsignorLocationName; _enquiry.ConsigneeCountryName = v.ConsigneeCountryName; _enquiry.ConsigneeCityName = v.ConsigneeCityName; _enquiry.Weight = Convert.ToDecimal(v.Weight); _enquiry.Consignee = v.Consignee; _enquiry.Consignor = v.Consignor; _enquiry.ConsignorAddress1_Building = v.ConsignorAddress; _enquiry.ConsignorAddress2_Street = v.ConsignorAddress1; _enquiry.ConsignorAddress3_PinCode = v.ConsignorAddress2; _enquiry.ConsigneeAddress1_Building = v.ConsigneeAddress; _enquiry.ConsigneeAddress2_Street = v.ConsigneeAddress1; _enquiry.ConsigneeAddress3_PinCode = v.ConsigneeAddress2; _enquiry.ConsignorPhone = v.ConsignorPhone; _enquiry.ConsigneePhone = v.ConsigneePhone; _enquiry.AssignedEmployeeID = v.EmployeeID; _enquiry.Remarks = v.Remarks; _enquiry.PickedUpEmpID = v.CollectedEmpID; _enquiry.PickedupDate = v.CollectedTime; //_enquiry.ShipmentType = v.ShipmentType; //if (v.vehreq == true) //{ // _enquiry.Vehicle = v.Vehicle; // _enquiry.VehicleID = v.VehicleID; //} _enquiry.ConsigneeContact = v.ConsigneeContact; _enquiry.ConsignorContact = v.ConsignorContact; _enquiry.EnteredByID = empid; //userid _enquiry.IsEnquiry = true; _enquiry.PickupReadyTime = v.ReadyTime; //_enquiry.OfficeTimeFrom = v.OfficeTimeFrom; //_enquiry.OfficeTimeTo = v.OfficeTimeTo; _enquiry.RequestSource = v.RequestSource; if (_enquiry.StatusTypeId == 1) { if (_enquiry.AssignedEmployeeID == null) { _enquiry.CourierStatusID = 1; } else if (_enquiry.AssignedEmployeeID != null && _enquiry.PickedUpEmpID == null) { _enquiry.CourierStatusID = 2; } //else if (_enquiry.PickedUpEmpID != null) //{ // _enquiry.PickupRequestStatusId = 3; //} else if (_enquiry.StatusTypeId == 1 && _enquiry.CourierStatusID == null) { _enquiry.CourierStatusID = 1; //request } } //db.CustomerEnquiries.Add(_enquiry); if (v.InScanID == 0) { db.InScanMasters.Add(_enquiry); db.SaveChanges(); // AWBTrackStatu _awbstatus = new AWBTrackStatu(); int? id = (from c in db.AWBTrackStatus orderby c.AWBTrackStatusId descending select c.AWBTrackStatusId).FirstOrDefault(); if (id == null) { id = 1; } else { id = id + 1; } _awbstatus.AWBTrackStatusId = Convert.ToInt32(id); _awbstatus.AWBNo = _enquiry.ConsignmentNo; _awbstatus.EntryDate = DateTime.Now; _awbstatus.InScanId = _enquiry.InScanID; _awbstatus.StatusTypeId = Convert.ToInt32(_enquiry.StatusTypeId); _awbstatus.CourierStatusId = Convert.ToInt32(_enquiry.CourierStatusID); _awbstatus.ShipmentStatus = db.tblStatusTypes.Find(_enquiry.StatusTypeId).Name; _awbstatus.CourierStatus = db.CourierStatus.Find(_enquiry.CourierStatusID).CourierStatus; _awbstatus.UserId = uid; db.AWBTrackStatus.Add(_awbstatus); db.SaveChanges(); // SaveConsignee(v); TempData["SuccessMsg"] = "You have successfully added Pickup Request."; } else { SaveConsignee(v); db.Entry(_enquiry).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully updated Pickup Request."; } return(RedirectToAction("Index")); //} //else //{ // int uid = Convert.ToInt32(Session["UserID"].ToString()); // UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault(); // int empid = u.UserID; // string empname = u.UserName; // ViewBag.Country = db.CountryMasters.ToList(); // ViewBag.City = db.CityMasters.ToList(); // ViewBag.Location = db.LocationMasters.ToList(); // ViewBag.Vehicle = db.VehicleMasters.ToList(); // ViewBag.Employee = db.EmployeeMasters.ToList(); // ViewBag.Customer = db.CustomerMasters.ToList(); // ViewBag.RequestType = db.RequestTypes.ToList(); // ViewBag.empname = empname; // ViewBag.empid = empid; // PickupRequestDAO doa = new PickupRequestDAO(); // ViewBag.RequestNo = doa.GetMaxPickupRequest(); // return View(); //} }
public ActionResult Create(InScanMasterVM v) { //PickupRequestDAO _dao = new PickupRequestDAO(); if (ModelState.IsValid) { int depotid = Convert.ToInt32(Session["CurrentDepotID"].ToString()); int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString()); int uid = Convert.ToInt32(Session["UserID"].ToString()); InScanMaster _enquiry = new InScanMaster(); int id = (from c in db.CustomerEnquiries orderby c.EnquiryID descending select c.EnquiryID).FirstOrDefault(); PickupRequestDAO _dao = new PickupRequestDAO(); string AWBNo = _dao.GetMaAWBNo(branchid); _enquiry.ConsignmentNo = v.AWBNo; _enquiry.TransactionDate = DateTime.Now; _enquiry.Consignor = v.Consignor; _enquiry.ConsignorContact = v.ConsignorContact; _enquiry.ConsignorPhone = v.ConsignorPhone; _enquiry.ConsignorAddress1_Building = v.ConsignorAddress1_Building; _enquiry.ConsignorAddress2_Street = v.ConsignorAddress2_Street; _enquiry.ConsignorAddress3_PinCode = v.ConsignorAddress2_Pincode; _enquiry.ConsignorCityName = v.ConsignorCityName; _enquiry.ConsignorCountryName = v.ConsignorCountryName; _enquiry.ConsignorLocationName = v.ConsignorLocationName; _enquiry.Consignee = v.Consignee; _enquiry.ConsigneeContact = v.ConsigneeContact; _enquiry.ConsigneePhone = v.ConsigneePhone; _enquiry.ConsigneeLocationName = v.ConsigneeLocationName; _enquiry.ConsigneeCountryName = v.ConsigneeCountryName; _enquiry.ConsigneeCityName = v.ConsigneeCityName; _enquiry.Weight = v.Weight; _enquiry.AcCompanyID = 1; _enquiry.CustomerID = v.CustomerID; _enquiry.PickedupDate = v.PickupDateTime; _enquiry.PickedUpEmpID = v.PickupBy; _enquiry.Remarks = v.Remarks; _enquiry.DepotReceivedBy = v.ReceivedByID; db.InScanMasters.Add(_enquiry); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully added InScan Master"; return(RedirectToAction("Index")); } else { int depotid = Convert.ToInt32(Session["CurrentDepotID"].ToString()); int userId = Convert.ToInt32(Session["CurrentUserID"].ToString()); ViewBag.depot = db.tblDepots.ToList(); //ViewBag.depot = (from c in db.tblDepots where c.ID == depotid select c).ToList(); ViewBag.employee = db.EmployeeMasters.ToList(); ViewBag.employeerec = db.EmployeeMasters.ToList(); ViewBag.Customer = db.CustomerMasters.ToList(); ViewBag.Movement = db.CourierMovements.ToList(); ViewBag.Employee = db.EmployeeMasters.ToList(); ViewBag.FAgent = db.ForwardingAgentMasters.ToList(); ViewBag.Movement = db.CourierMovements.ToList(); ViewBag.ProductType = db.ProductTypes.ToList(); ViewBag.parceltype = db.ParcelTypes.ToList(); ViewBag.customerrate = db.CustomerRates.ToList(); ViewBag.TypeofGoods = db.TypeOfGoods.ToList(); ViewBag.CourierDescription = db.CourierDescriptions.ToList(); //InScanMasterVM obj = new InScanMasterVM(); //obj.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); //obj.DepotID = Convert.ToInt32(Session["CurrentDepotID"].ToString()); //obj.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); //obj.DeviceID = "WebSite"; //int pickedupid = (from e in db.EmployeeMasters where e.UserID == userId select e.EmployeeID).First(); //obj.TransactionDate = DateTime.Now; return(View(v)); } //else //{ // int uid = Convert.ToInt32(Session["UserID"].ToString()); // UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault(); // int empid = u.UserID; // string empname = u.UserName; // ViewBag.Country = db.CountryMasters.ToList(); // ViewBag.City = db.CityMasters.ToList(); // ViewBag.Location = db.LocationMasters.ToList(); // ViewBag.Vehicle = db.VehicleMasters.ToList(); // ViewBag.Employee = db.EmployeeMasters.ToList(); // ViewBag.Customer = db.CustomerMasters.ToList(); // ViewBag.RequestType = db.RequestTypes.ToList(); // ViewBag.empname = empname; // ViewBag.empid = empid; // PickupRequestDAO doa = new PickupRequestDAO(); // ViewBag.RequestNo = doa.GetMaxPickupRequest(); // return View(); //} }