public ActionResult DeleteConfirmed(int id) { InScanMaster a = db.InScanMasters.Find(id); if (a == null) { return(HttpNotFound()); } else { a.IsDeleted = true; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully deleted Pickup Request."; return(RedirectToAction("Index")); } }
public JsonResult GetStatus(int InScanID) { string status = "ok"; ChangeStatus _cstatus = new ChangeStatus(); try { InScanMaster _inscan = db.InScanMasters.Find(InScanID); _cstatus.InScanID = _inscan.InScanID; _cstatus.StatusType = db.tblStatusTypes.Where(cc => cc.ID == _inscan.StatusTypeId).FirstOrDefault().Name; _cstatus.ChangeStatusId = Convert.ToInt32(_inscan.CourierStatusID); if (_inscan.PickedUpEmpID != null) { _cstatus.PickedUpId = Convert.ToInt32(_inscan.PickedUpEmpID); } if (_inscan.AssignedEmployeeID != null) { _cstatus.AssignedEmployee = Convert.ToInt32(_inscan.AssignedEmployeeID); } if (_inscan.PickedupDate != null) { _cstatus.PickedUpDateTime = Convert.ToDateTime(_inscan.PickedupDate); } if (_inscan.SubReasonId != null) { _cstatus.SubStatusReason = Convert.ToInt32(_inscan.SubReasonId); } } catch (Exception ex) { status = ex.Message; } return(Json(new { data = _cstatus, result = status }, JsonRequestBehavior.AllowGet)); }
public PickupRequestVM GetPickupRequestDetail(int id) { PickupRequestVM v = new PickupRequestVM(); InScanMaster a = db.InScanMasters.Find(id); v.InScanID = a.InScanID; v.BranchID = a.BranchID; v.DepotID = a.DepotID; v.EnquiryID = a.InScanID; v.EnquiryNo = a.EnquiryNo; v.AWBNo = a.ConsignmentNo; v.EnquiryDate = a.PickupRequestDate; v.DescriptionID = 4; v.ConsignorCountryName = a.ConsignorCountryName; v.ConsignorCityName = a.ConsignorCityName; v.ConsignorLocationName = a.ConsignorLocationName; v.ConsigneeCountryName = a.ConsigneeCountryName; v.ConsigneeCityName = a.ConsigneeCityName; v.ConsigneeLocationName = a.ConsigneeLocationName; v.Weight = Convert.ToDouble(a.Weight); v.AcCompanyID = a.AcCompanyID; v.CustomerID = a.CustomerID; string customername = db.CustomerMasters.Find(v.CustomerID).CustomerName; v.CustomerName = customername; v.Consignee = a.Consignee; v.Consignor = a.Consignor; v.ConsignorAddress = a.ConsignorAddress1_Building; v.ConsignorAddress1 = a.ConsignorAddress2_Street; v.ConsignorAddress2 = a.ConsignorAddress3_PinCode; v.ConsigneeAddress = a.ConsigneeAddress1_Building; v.ConsigneeAddress1 = a.ConsigneeAddress2_Street; v.ConsigneeAddress2 = a.ConsigneeAddress3_PinCode; v.ConsignorPhone = a.ConsignorPhone; v.ConsigneePhone = a.ConsigneePhone; v.ConsignorCountryName = a.ConsignorCountryName; v.ConsigneeCountryName = a.ConsigneeCountryName; v.ConsignorCityName = a.ConsignorCityName; v.ConsigneeCityName = a.ConsigneeCityName; //v.PickupRequestStatusId = a.PickupRequestStatusId; v.PickupRequestStatusId = a.CourierStatusID; v.SubReasonId = a.SubReasonId; v.EmployeeID = a.AssignedEmployeeID; v.Remarks = a.Remarks; v.CollectedEmpID = a.PickedUpEmpID;; v.CollectedTime = a.PickedupDate;; //v.ShipmentType = a.ShipmentType; //if (a.VehicleID != null) //{ // v.VehicleID = a.VehicleID.Value; // v.Vehicle = a.Vehicle; // v.vehreq = true; //} //else //{ // v.vehreq = false; // v.Vehicle = ""; //} v.IsEnquiry = a.IsEnquiry; v.ConsigneeContact = a.ConsigneeContact; v.ConsignorContact = a.ConsignorContact; v.EnteredByID = a.EnteredByID; v.ReadyTime = a.PickupReadyTime; CustomerMaster cm = db.CustomerMasters.Where(cm1 => cm1.CustomerID == a.CustomerID).FirstOrDefault(); v.CustomerCode = cm.CustomerCode; v.OfficeTimeFrom = cm.OfficeOpenTime; v.OfficeTimeTo = cm.OfficeCloseTime; v.RequestSource = a.RequestSource; //v.Documents v.DocumentTypeId = a.DocumentTypeId; return(v); }
public ActionResult Edit(int id) { 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.Location = db.LocationMasters.ToList(); ViewBag.Vehicle = db.VehicleMasters.ToList(); ViewBag.Employee = db.EmployeeMasters.ToList(); ViewBag.Customer = db.CustomerMasters.ToList(); ViewBag.empname = empname; ViewBag.empid = empid; PickupRequestVM v = new PickupRequestVM(); //CustomerEnquiry a = db.CustomerEnquiries.Find(id); InScanMaster a = db.InScanMasters.Find(id); if (a == null) { return(HttpNotFound()); } else { v.EnquiryID = a.InScanID; v.EnquiryNo = a.EnquiryNo; v.AWBNo = a.ConsignmentNo; v.EnquiryDate = a.PickupRequestDate; v.DescriptionID = 4; //v.ConsignerCountryId = a.ConsignerCountryId; //v.ConsignerCityId = 19; // a.ConsignerCityId; //v.ConsignerLocationId = 7;// a.ConsignerLocationId; v.ConsignorCountryName = a.ConsignorCountryName; v.ConsignorCityName = a.ConsignorCityName; v.ConsignorLocationName = a.ConsignorLocationName; //v.ConsigneeCountryID = a.ConsigneeCountryID; //v.ConsigneeCityId = a.ConsigneeCityId; v.ConsigneeCountryName = a.ConsigneeCountryName; v.ConsigneeCityName = a.ConsigneeCityName; //v.ConsigneeLocationId = a.ConsigneeLocationId; v.ConsigneeLocationName = a.ConsigneeLocationName; v.Weight = Convert.ToDouble(a.Weight); v.AcCompanyID = 1; v.CustomerID = a.CustomerID; v.Consignee = a.Consignee; v.Consignor = a.Consignor; v.ConsignorAddress = a.ConsignorAddress1_Building; v.ConsignorAddress1 = a.ConsignorAddress2_Street; v.ConsignorAddress2 = a.ConsignorAddress3_PinCode; v.ConsigneeAddress = a.ConsigneeAddress1_Building; v.ConsigneeAddress1 = a.ConsigneeAddress2_Street; v.ConsigneeAddress2 = a.ConsigneeAddress3_PinCode; v.ConsignorPhone = a.ConsignorPhone; v.ConsigneePhone = a.ConsigneePhone; v.EmployeeID = a.AssignedEmployeeID; v.Remarks = a.Remarks; v.CollectedEmpID = a.PickedUpEmpID;; v.CollectedTime = a.PickedupDate;; //v.ShipmentType = a.ShipmentType; //if (a.VehicleID != null) //{ // v.VehicleID = a.VehicleID.Value; // v.Vehicle = a.Vehicle; // v.vehreq = true; //} //else //{ // v.vehreq = false; // v.Vehicle = ""; //} v.IsEnquiry = a.IsEnquiry; v.ConsigneeContact = a.ConsigneeContact; v.ConsignorContact = a.ConsignorContact; v.EnteredByID = empid; v.ReadyTime = a.PickupReadyTime; CustomerMaster cm = db.CustomerMasters.Where(cm1 => cm1.CustomerID == a.CustomerID).FirstOrDefault(); v.CustomerCode = cm.CustomerCode; v.OfficeTimeFrom = cm.OfficeOpenTime; v.OfficeTimeTo = cm.OfficeCloseTime; v.RequestSource = a.RequestSource; } //var obj = (from c in db.CityMasters where c.CountryID == a.ConsignerCountryId select c).ToList(); //ViewBag.City = (from c in db.CityMasters where c.CountryID == a.ConsignerCountryId select c).ToList(); //ViewBag.CityConsignee = (from c in db.CityMasters where c.CountryID == a.ConsigneeCountryID select c).ToList(); return(View(v)); }
public JsonResult SaveStatus(ChangeStatus v) { int uid = Convert.ToInt32(Session["UserID"].ToString()); string status = "ok"; string message = ""; bool statuschangepersmission = true; try { InScanMaster _enquiry = db.InScanMasters.Find(v.InScanID); //admin level rights checking to revert the status if (_enquiry.CourierStatusID > v.ChangeStatusId) { List <int> RoleId = (List <int>)Session["RoleID"]; if (RoleId[0] != 1) { statuschangepersmission = false; } } if (statuschangepersmission == false) { status = "failed"; return(Json(new { status = status, message = "User does not have persmission to revert the status,Contact Admin!" }, JsonRequestBehavior.AllowGet)); } if (v.ChangeStatusId == 2) { _enquiry.AssignedEmployeeID = v.AssignedEmployee; _enquiry.CourierStatusID = 2; } else if (v.ChangeStatusId == 3) { _enquiry.CourierStatusID = 3; _enquiry.SubReasonId = v.SubStatusReason; } else if (v.ChangeStatusId == 4) { _enquiry.PickedUpEmpID = v.PickedUpId; _enquiry.PickedupDate = v.PickedUpDateTime; _enquiry.CourierStatusID = 4; } db.Entry(_enquiry).State = EntityState.Modified; db.SaveChanges(); //updateing awbstaus table for tracking 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(); message = "Status Changed Successfully!"; } catch (Exception ex) { status = "failed"; message = ex.Message; } return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet)); }
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(); //} }
public JsonResult SaveQuickInScan(InScanVM v) { //InScan inscan = new InScan(); int UserId = Convert.ToInt32(Session["UserID"].ToString()); int BranchId = Convert.ToInt32(Session["CurrentBranchID"].ToString()); int CompanyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); int yearid = Convert.ToInt32(Session["fyearid"].ToString()); var inscanitems = v.SelectedInScanId.Split(','); try { QuickInscanMaster _qinscan = new QuickInscanMaster(); if (v.QuickInscanID > 0) { _qinscan = db.QuickInscanMasters.Find(v.QuickInscanID); } else { int?maxid = (from c in db.QuickInscanMasters orderby c.QuickInscanID descending select c.QuickInscanID).FirstOrDefault(); if (maxid == null) { _qinscan.QuickInscanID = 1; } else { _qinscan.QuickInscanID = Convert.ToInt32(maxid) + 1; } _qinscan.AcFinancialYearID = yearid; } _qinscan.InscanSheetNumber = v.InScanSheetNo; _qinscan.AcCompanyId = CompanyId; _qinscan.ReceivedByID = v.ReceivedByID; _qinscan.CollectedByID = v.CollectedByID; _qinscan.QuickInscanDateTime = v.QuickInscanDateTime; _qinscan.VehicleId = v.VehicleId; _qinscan.DriverName = v.DriverName; _qinscan.BranchId = BranchId; _qinscan.DepotId = v.DepotID; _qinscan.UserId = UserId; _qinscan.Source = "Inhouse"; if (v.QuickInscanID > 0) { db.Entry(_qinscan).State = EntityState.Modified; var removeinscanitems = v.RemovedInScanId.Split(','); foreach (var _item in removeinscanitems) { int _inscanid = Convert.ToInt32(_item); var _inscan = db.InScanMasters.Find(_inscanid); _inscan.QuickInscanID = null; _inscan.PickedUpEmpID = null; _inscan.DepotReceivedBy = null; //_inscan.TransactionDate = v.QuickInscanDateTime; //_inscan.VehicleID = null; _inscan.StatusTypeId = db.tblStatusTypes.Where(cc => cc.Name == "PICKUP REQUEST").First().ID; _inscan.CourierStatusID = db.CourierStatus.Where(cc => cc.StatusTypeID == _inscan.StatusTypeId && cc.CourierStatus == "Assigned For Collections").FirstOrDefault().CourierStatusID; db.Entry(_inscan).State = EntityState.Modified; db.SaveChanges(); //updateing awbstaus table for tracking 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 = _inscan.ConsignmentNo; _awbstatus.EntryDate = DateTime.Now; _awbstatus.InScanId = _inscan.InScanID; _awbstatus.StatusTypeId = Convert.ToInt32(_inscan.StatusTypeId); _awbstatus.CourierStatusId = Convert.ToInt32(_inscan.CourierStatusID); _awbstatus.ShipmentStatus = db.tblStatusTypes.Find(_inscan.StatusTypeId).Name; _awbstatus.CourierStatus = db.CourierStatus.Find(_inscan.CourierStatusID).CourierStatus; _awbstatus.UserId = UserId; db.AWBTrackStatus.Add(_awbstatus); db.SaveChanges(); } } else { db.QuickInscanMasters.Add(_qinscan); db.SaveChanges(); } foreach (var item in inscanitems) { int _inscanid = Convert.ToInt32(item); InScanMaster _inscan = db.InScanMasters.Find(_inscanid); _inscan.QuickInscanID = _qinscan.QuickInscanID; _inscan.PickedUpEmpID = v.CollectedByID; _inscan.DepotReceivedBy = v.ReceivedByID; //_inscan.TransactionDate = v.QuickInscanDateTime; //_inscan.VehicleID = v.VehicleId; _inscan.StatusTypeId = db.tblStatusTypes.Where(cc => cc.Name == "INSCAN").First().ID; _inscan.CourierStatusID = db.CourierStatus.Where(cc => cc.StatusTypeID == _inscan.StatusTypeId && cc.CourierStatus == "Received at Origin Facility").FirstOrDefault().CourierStatusID; db.Entry(_inscan).State = EntityState.Modified; db.SaveChanges(); } //TempData["SuccessMsg"] = "You have successfully Saved InScan Items."; return(Json(new { status = "ok", message = "You have successfully Saved InScan Items.!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { status = "Failed", message = ex.Message }, JsonRequestBehavior.AllowGet)); //return Json("Failed", JsonRequestBehavior.AllowGet); } }
public ActionResult Edit(CustomerInvoiceVM model) { var userid = Convert.ToInt32(Session["UserID"]); if (model.CustomerInvoiceID > 0) { CustomerInvoice _custinvoice = new CustomerInvoice(); _custinvoice = db.CustomerInvoices.Find(model.CustomerInvoiceID); _custinvoice.InvoiceDate = model.InvoiceDate; _custinvoice.TaxPercent = model.TaxPercent; _custinvoice.InvoiceTotal = model.InvoiceTotal; _custinvoice.Remarks = model.Remarks; _custinvoice.ModifiedBy = userid; _custinvoice.ModifiedDate = CommanFunctions.GetCurrentDateTime(); db.Entry(_custinvoice).State = EntityState.Modified; db.SaveChanges(); List <CustomerInvoiceDetailVM> e_Details = model.CustomerInvoiceDetailsVM; // Session["InvoiceListing"] as List<CustomerInvoiceDetailVM>; model.CustomerInvoiceDetailsVM = e_Details; if (model.CustomerInvoiceDetailsVM != null) { foreach (var e_details in model.CustomerInvoiceDetailsVM) { if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked) { CustomerInvoiceDetail _detail = new CustomerInvoiceDetail(); _detail.CustomerInvoiceDetailID = db.CustomerInvoiceDetails.Select(x => x.CustomerInvoiceDetailID).DefaultIfEmpty(0).Max() + 1; _detail.CustomerInvoiceID = _custinvoice.CustomerInvoiceID; _detail.ConsignmentNo = e_details.ConsignmentNo; _detail.InScanID = e_details.InScanID; //_detail.StatusPaymentMode = e_details.StatusPaymentMode; _detail.FreightCharge = e_details.FreightCharge; _detail.CustomsCharge = e_details.CustomsCharge; _detail.DocCharge = e_details.DocCharge; _detail.OtherCharge = e_details.OtherCharge; db.CustomerInvoiceDetails.Add(_detail); db.SaveChanges(); //inscan invoice modified InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID); _inscan.InvoiceID = _custinvoice.CustomerInvoiceID; db.Entry(_inscan).State = EntityState.Modified; db.SaveChanges(); RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault(); _revenueupdate.InvoiceId = _custinvoice.CustomerInvoiceID; db.Entry(_revenueupdate).State = EntityState.Modified; db.SaveChanges(); } else if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked == false) { //CustomerInvoiceDetail _detail = new CustomerInvoiceDetail(); //_detail = db.CustomerInvoiceDetails.Find(e_details.CustomerInvoiceID); //_detail.CourierCharge = e_details.CourierCharge; //_detail.CustomCharge = e_details.CustomCharge; //_detail.OtherCharge = e_details.OtherCharge; //db.CustomerInvoiceDetails.Add(_detail); //db.SaveChanges(); ////inscan invoice modified //InScanMaster _inscan = db.InScanMasters.Find(e_details.InscanID); //_inscan.InvoiceID = _custinvoice.CustomerInvoiceID; //db.Entry(_inscan).State = System.Data.EntityState.Modified; //db.SaveChanges(); } else if (e_details.CustomerInvoiceDetailID > 0 && e_details.AWBChecked == false) { CustomerInvoiceDetail _detail = new CustomerInvoiceDetail(); _detail = db.CustomerInvoiceDetails.Find(e_details.CustomerInvoiceDetailID); db.CustomerInvoiceDetails.Remove(_detail); db.SaveChanges(); ////inscan invoice modified InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID); _inscan.InvoiceID = null; db.Entry(_inscan).State = EntityState.Modified; db.SaveChanges(); RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault(); List <RevenueUpdateDetail> revenueUpdateDetails = db.RevenueUpdateDetails.Where(cc => cc.MasterID == _revenueupdate.ID).ToList(); foreach (RevenueUpdateDetail item in revenueUpdateDetails) { item.InvoiceId = null; db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } //_revenueupdate.InvoiceId = null; //db.Entry(_revenueupdate).State = EntityState.Modified; //db.SaveChanges(); } } } //Accounts Posting PickupRequestDAO _dao = new PickupRequestDAO(); _dao.GenerateInvoicePosting(_custinvoice.CustomerInvoiceID); TempData["SuccessMsg"] = "You have successfully Updated the Customer Invoice"; return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }
public ActionResult Create(CustomerInvoiceVM model) { int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString()); int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString()); var userid = Convert.ToInt32(Session["UserID"]); int yearid = Convert.ToInt32(Session["fyearid"].ToString()); if (model.CustomerInvoiceID == 0) { CustomerInvoice _custinvoice = new CustomerInvoice(); var max = db.CustomerInvoices.Select(x => x.CustomerInvoiceID).DefaultIfEmpty(0).Max() + 1; _custinvoice.CustomerInvoiceID = max; _custinvoice.CustomerInvoiceNo = model.CustomerInvoiceNo; _custinvoice.InvoiceDate = model.InvoiceDate; _custinvoice.CustomerID = model.CustomerID; //_custinvoice.CustomerInvoiceTax = model.CustomerInvoiceTax; //_custinvoice.ChargeableWT = model.ChargeableWT; //_custinvoice.AdminPer = model.AdminPer; //_custinvoice.AdminAmt = model.AdminAmt; //_custinvoice.FuelPer = model.FuelPer; //_custinvoice.FuelAmt = model.FuelAmt; //_custinvoice.OtherCharge = model.OtherCharge; _custinvoice.InvoiceTotal = model.InvoiceTotal; _custinvoice.AcFinancialYearID = yearid; _custinvoice.AcCompanyID = companyId; _custinvoice.BranchID = branchid; _custinvoice.Remarks = model.Remarks; _custinvoice.CreatedBy = userid; _custinvoice.CreatedDate = CommanFunctions.GetCurrentDateTime(); _custinvoice.ModifiedBy = userid; _custinvoice.ModifiedDate = CommanFunctions.GetCurrentDateTime(); db.CustomerInvoices.Add(_custinvoice); db.SaveChanges(); List <CustomerInvoiceDetailVM> e_Details = model.CustomerInvoiceDetailsVM; // Session["InvoiceListing"] as List<CustomerInvoiceDetailVM>; model.CustomerInvoiceDetailsVM = e_Details; if (model.CustomerInvoiceDetailsVM != null) { foreach (var e_details in model.CustomerInvoiceDetailsVM) { if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked) { CustomerInvoiceDetail _detail = new CustomerInvoiceDetail(); _detail.CustomerInvoiceDetailID = db.CustomerInvoiceDetails.Select(x => x.CustomerInvoiceDetailID).DefaultIfEmpty(0).Max() + 1; _detail.CustomerInvoiceID = _custinvoice.CustomerInvoiceID; _detail.ConsignmentNo = e_details.ConsignmentNo; _detail.InScanID = e_details.InScanID; //_detail.StatusPaymentMode = e_details.StatusPaymentMode; _detail.FreightCharge = e_details.FreightCharge; _detail.CustomsCharge = e_details.CustomsCharge; _detail.OtherCharge = e_details.OtherCharge; _detail.DocCharge = e_details.DocCharge; _detail.NetValue = e_details.TotalCharges; db.CustomerInvoiceDetails.Add(_detail); db.SaveChanges(); //inscan invoice modified InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID); _inscan.InvoiceID = _custinvoice.CustomerInvoiceID; db.Entry(_inscan).State = EntityState.Modified; db.SaveChanges(); RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault(); var revenuedetails = db.RevenueUpdateDetails.Where(cc => cc.MasterID == _revenueupdate.ID && cc.InvoiceId == null).ToList(); foreach (var revdetail in revenuedetails) { revdetail.InvoiceId = _custinvoice.CustomerInvoiceID; db.Entry(revdetail).State = EntityState.Modified; db.SaveChanges(); } _revenueupdate.InvoiceId = _custinvoice.CustomerInvoiceID; db.Entry(_revenueupdate).State = EntityState.Modified; db.SaveChanges(); } } } //Accounts Posting PickupRequestDAO _dao = new PickupRequestDAO(); _dao.GenerateInvoicePosting(_custinvoice.CustomerInvoiceID); TempData["SuccessMsg"] = "You have successfully Saved the Customer Invoice"; return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }