public ActionResult Create(InScan v) { if (ModelState.IsValid) { db.InScans.Add(v); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully added Location."; return(RedirectToAction("Index")); } return(View(v)); }
public ActionResult Create(AWBillVM v) { try { string AWBNo = string.Empty; if (v.AWBNO != string.Empty) { AWBNo = v.AWBNO; } else { string aw = (from c in db.InScans orderby c.AWBNo descending select c.AWBNo).FirstOrDefault(); int a = Convert.ToInt32(aw) + 1; AWBNo = a.ToString(); } int CurrentBranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); var ahead = db.AcHeadAssigns.FirstOrDefault(); // commented on sep 21 2020 Where(x => x.BranchID == CurrentBranchID).FirstOrDefault(); try { var ajm = new AcJournalMaster() { AcJournalID = GetMaxAcJournalID() + 1, VoucherNo = "C.Note" + AWBNo, TransDate = DateTime.UtcNow, AcFinancialYearID = Convert.ToInt32(Session["CurrentYear"].ToString()), VoucherType = "DX", TransType = 1, StatusDelete = false, Remarks = "", UserID = Convert.ToInt32(Session["UserID"].ToString()), AcCompanyID = Convert.ToInt32(Session["CurrenctCompanyID"].ToString()), //BranchID = this.CurrentBranchID, Reference = "", ShiftID = 0, }; db.AcJournalMasters.Add(ajm); db.SaveChanges(); if (v.paymentmode != "CSR" && v.TotalCharges > 0) { if (ahead != null) { int aheadassign = 0; switch (v.paymentmode) { case "COD": aheadassign = ahead.CODControlID.Value; break; //CODControlID case "FOC": aheadassign = ahead.FOCControlID.Value; break; //FOCControlID case "PKP": aheadassign = ahead.ProvisionCostControlAcID.Value; break; //UnPostedSalesAcHeadID default: break; } if (aheadassign != 0 && Convert.ToDecimal(v.TotalCharges) != 0) { AcJournalDetail ajd = new AcJournalDetail() { AcJournalDetailID = GetMaxAcJournalDetailID() + 1, AcJournalID = ajm.AcJournalID, AcHeadID = aheadassign, Amount = Convert.ToDecimal(v.TotalCharges), Remarks = "", }; db.AcJournalDetails.Add(ajd); db.SaveChanges(); ajd = new AcJournalDetail() { AcJournalDetailID = GetMaxAcJournalDetailID() + 1, AcJournalID = ajm.AcJournalID, AcHeadID = aheadassign, Amount = -Convert.ToDecimal(v.TotalCharges), Remarks = "", }; db.AcJournalDetails.Add(ajd); db.SaveChanges(); } } } else if (v.paymentmode == "CSR" && v.TotalCharges > 0) { AcJournalDetail ajd = new AcJournalDetail() { AcJournalDetailID = GetMaxAcJournalDetailID() + 1, AcJournalID = ajm.AcJournalID, AcHeadID = ahead.MaterialCostControlReceivableAcHeadID, Amount = Convert.ToDecimal(v.TotalCharges), Remarks = "", }; db.AcJournalDetails.Add(ajd); db.SaveChanges(); ajd = new AcJournalDetail() { AcJournalDetailID = GetMaxAcJournalDetailID() + 1, AcJournalID = ajm.AcJournalID, AcHeadID = ahead.MaterialCostControlReceivableAcHeadID, Amount = -Convert.ToDecimal(v.TotalCharges), Remarks = "", }; db.AcJournalDetails.Add(ajd); db.SaveChanges(); } InScan inscan = new InScan(); inscan.InScanID = GetMaxInscanID(); //inscan.AWBNumberMode = IsAWBAutoManual; inscan.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); inscan.AWBNo = AWBNo; inscan.Remarks = v.Remarks; inscan.UserID = Convert.ToInt32(Session["UserID"].ToString()); inscan.EnquiryID = 0; inscan.StatusClose = false; inscan.MovementID = v.movementID; inscan.AcJournalID = ajm.AcJournalID; inscan.AcCompanyID = Convert.ToInt32(Session["CurrenctCompanyID"].ToString()); inscan.StatusReconciled = false; if (v.Date != null) { inscan.InScanDate = v.Date.Value; //inscan.InScanDate = DateTime.Parse(deDate.SelectedDate.Value.Date.ToString("dd/MM/yyyy") + " " + deDate.SelectedDate.Value.ToString("HH:mm:ss")); //DateTime.Parse(deDate.SelectedDate.Value.Date.ToString("dd/MM/yyyy") + " " + this.rtpTime.SelectedDate.Value.ToString("HH:mm:ss")), } inscan.StatusInScan = "CN"; inscan.CustomerRateTypeID = 0; if (v.CustomerRateTypeID != null) { inscan.CustomerRateTypeID = v.CustomerRateTypeID; } inscan.Tax = 0; if (v.Tax != null) { inscan.Tax = v.Tax; } if (v.Pieces != null) { inscan.Pieces = v.Pieces; } inscan.StatedWeight = 0; if (v.Weight != null) { inscan.StatedWeight = v.Weight; } inscan.CourierDescriptionID = 0; if (v.CourierType != null) { inscan.CourierDescriptionID = v.CourierType; } inscan.CourierServiceID = 0; if (v.ProductType != null) { inscan.CourierServiceID = v.ProductType; } if (v.Agent != null) { inscan.IAgentID = 0; inscan.PickupCharges = 0; inscan.CollectedAmount = 0; inscan.PickupCharges = 0; inscan.CollectedBy = 0; inscan.ReceivedBy = 0; if (v.Agent != null) { inscan.IAgentID = Convert.ToInt32(v.Agent); if (v.collectedamt != null) { inscan.CollectedAmount = Convert.ToDecimal(v.collectedamt); } if (v.pickupcharge != null) { inscan.PickupCharges = Convert.ToDecimal(v.pickupcharge); } } } else { if (v.CollectedByDetails != null) { inscan.CollectedBy = v.CollectedByDetails; } } inscan.ReceivedBy = 0; if (v.ReceivedBy != null) { inscan.ReceivedBy = v.ReceivedBy; } inscan.CourierCharge = 0; if (v.CourierCharges != null) { inscan.CourierCharge = v.CourierCharges; } inscan.OtherCharge = 0; if (v.OtherCharges != null) { inscan.OtherCharge = v.OtherCharges; } inscan.ServiceCharge = 0; if (v.ServiceCharges != null) { inscan.ServiceCharge = v.ServiceCharges; } inscan.PackingCharge = 0; if (v.PackingCharges != null) { inscan.PackingCharge = v.PackingCharges; } if (v.paymentmode != null) { inscan.StatusPaymentMode = v.paymentmode; } inscan.OriginID = 0; if (v.origincountry != null) { inscan.OriginID = v.origincountry; } if (v.destinationCountry != null) { inscan.DestinationID = v.destinationCountry.ToString(); } inscan.ConsignorCityID = 0; if (v.origincity != null) { inscan.ConsignorCityID = v.origincity; } inscan.ConsigneeCityID = 0; if (v.destinationCity != null) { inscan.ConsigneeCityID = v.destinationCity; } if (v.CourierMode != null && v.CourierType != null) { inscan.TaxconfigurationID = (from tc1 in db.TaxConfigurations where tc1.EffectFromDate <= DateTime.UtcNow && tc1.CourierMoveMentID == Convert.ToInt32(v.CourierMode) && tc1.ParcelTypeId == v.CourierType select tc1.TaxConfigurationID).FirstOrDefault(); } inscan.CustomerID = 0; if (v.CustomerID != null) { inscan.CustomerID = v.CustomerID; } inscan.Consignee = v.consignee; inscan.Consignor = v.shipper; inscan.ConsigneeAddress = v.Consigneeaddress; inscan.ConsignorAddress = v.shipperaddress; if (v.ConsigneePhone != null) { inscan.ConsigneePhone = v.ConsigneePhone; } if (v.shipperphone != null) { inscan.ConsignorPhone = v.shipperphone; } inscan.ConsigneeCountryID = 0; if (v.destinationCountry != null) { inscan.ConsigneeCountryID = v.destinationCountry; } inscan.ConsignorCountryID = 0; if (v.origincountry != null) { inscan.ConsignorCountryID = v.origincountry; } if (v.originlocation != null) { inscan.ConsignorLocation = v.originlocation; } if (v.destinationLocation != null) { inscan.ConsigneeLocation = v.destinationLocation; } inscan.AcTaxJournalID = 0; inscan.BalanceAmt = 0; if (v.TotalCharges != null) { inscan.BalanceAmt = v.TotalCharges; } inscan.TypeOfGoodID = 0; if (v.InvoiceValue != null) { inscan.InvoiceValue = v.InvoiceValue; } inscan.MaterialCost = 0; if (v.MaterialCost != null) { inscan.MaterialCost = v.MaterialCost; } inscan.ReferenceAWBNo = v.ReferenceNumber; inscan.MaterialDescription = v.MaterialDescription; if (v.RevisedRate != null) { inscan.RevisedRate = v.RevisedRate; } if (v.SpecialInstructions != null) { inscan.SpecialInstructions = v.SpecialInstructions; } inscan.ConsigneeAddress1 = ""; inscan.ConsigneeAddress2 = ""; inscan.ConsignorAddress1 = ""; inscan.ConsignorAddress2 = ""; inscan.ConsigneeContact = v.consigneecontact; inscan.ConsignorContact = v.consigneecontact; inscan.CargoDescription = v.CargoDescription; inscan.HandlingInstruction = v.HandlingInstructions; inscan.CustomsCollectedBy = 0; if (v.ReceivedBy != null) { inscan.CustomsCollectedBy = v.ReceivedBy; } db.InScans.Add(inscan); db.SaveChanges(); InScanInternationalDeatil isid = new InScanInternationalDeatil(); isid.InScanID = 0; ////InScanInternationalDeatilID = Common.GetMaxNumber("InScanInternationalDeatilID", "InScanInternationalDeatils"), isid.InScanID = inscan.InScanID; ////InscanInternationalID = isi.InScanInternationalID, isid.VerifiedWeight = 0; if (v.VerifiedWeight != null) { isid.VerifiedWeight = Convert.ToDecimal(v.VerifiedWeight); } //if (txtForwardingCharge.Text != string.Empty) //{ // isid.ForwardingCharge = Convert.ToDecimal(txtForwardingCharge.Value); //} ////context.InScanInternationalDeatils.InsertOnSubmit(isid); InScanInternational isi = new InScanInternational(); ////InScanInternationalID = Common.GetMaxNumber("InScanInternationalID", "InScanInternational"), ////FAgentID = -1, isi.FAgentID = 0; if (v.ForwardingAgentID != null) { isi.FAgentID = v.ForwardingAgentID; } else { isi.FAgentID = 0; } if (v.ForwardingDate != null) { isi.ForwardingDate = v.ForwardingDate.Value; } isi.VerifiedWeight = 0; if (v.VerifiedWeight != null) { isi.VerifiedWeight = v.VerifiedWeight; } //if (txtForwardingCharge.Text != string.Empty) //{ // isi.ForwardingCharge = Convert.ToDecimal(txtForwardingCharge.Value); //} isi.StatusAssignment = false; isi.ForwardingAWBNo = v.ForwardingAWB; isid.InscanInternationalID = isi.InScanInternationalID; isi.InScanID = inscan.InScanID; if (v.ForwardingAgentID != null) { isi.FAgentID = v.ForwardingAgentID; } if (v.ForwardingDate != null) { isi.ForwardingDate = v.ForwardingDate.Value; } db.InScanInternationals.Add(isi); db.SaveChanges(); db.InScanInternationalDeatils.Add(isid); db.SaveChanges(); int max = (from c in db.AWBStatus orderby c.AWBStatusID descending select c.AWBStatusID).FirstOrDefault(); if (max == null) { max = 1; } else { max = max + 1; } AWBStatu astat = new AWBStatu() { AWBStatusID = max, StatusDescriptionID = inscan.InScanID, AWBNO = AWBNo, Date = inscan.InScanDate, Status = "DetailsUpdated", FormID = "IN", }; db.AWBStatus.Add(astat); db.SaveChanges(); } catch (Exception e) { } } catch (Exception ex) { } return(RedirectToAction("Index")); }
public ActionResult ImportData() { int id = Convert.ToInt32(Session["ImpExpID"].ToString()); var data = (from c in db.tempTables where c.ImportID == id orderby c.AWBNo ascending select c).ToList(); foreach (var item in data) { string dest = item.DestinationLocation; string cby = item.CollectedBy; string rcby = item.ReceivedBy; string ctype = item.CourierType; string branch = item.Branch; string fagent = item.FAgent; string origin = item.OriginCounty; string move = item.CourierMovementType; // string prdcd = item.ProductType; // string crt = item.CustmorRateType; int destinationID = (from c in db.CountryMasters where c.CountryName.Equals(dest) select c.CountryID).FirstOrDefault(); int CollectedByemp = (from c in db.EmployeeMasters where c.EmployeeName.Equals(cby) select c.EmployeeID).FirstOrDefault(); int recbyemp = (from c in db.EmployeeMasters where c.EmployeeName.Equals(rcby) select c.EmployeeID).FirstOrDefault(); int ctypeid = (from c in db.ParcelTypes where c.ParcelType1.Equals(ctype) select c.ID).FirstOrDefault(); int fagentid = (from c in db.ForwardingAgentMasters where c.FAgentName.Equals(fagent) select c.FAgentID).FirstOrDefault(); int branchid = (from c in db.BranchMasters where c.BranchName.Equals(branch) select c.BranchID).FirstOrDefault(); int origincountryid = (from c in db.CountryMasters where c.CountryName.Equals(origin) select c.CountryID).FirstOrDefault(); int coumoveid = (from c in db.CourierMovements where c.MovementType.Equals(move) select c.MovementID).FirstOrDefault(); //int prd = (from c in db.ProductTypes where c.ProductName.Equals(prdcd) select c.ProductTypeID).FirstOrDefault(); //int crtd = (from c in db.CustomerRateTypes where c.CustomerRateType1.Equals(crt) select c.CustomerRateTypeID).FirstOrDefault(); int max = (from c in db.InScans orderby c.InScanID descending select c.InScanID).FirstOrDefault(); InScan s = new InScan(); s.InScanID = max + 1; s.AWBNo = item.AWBNo; s.CourierCharge = item.CourierCharge; s.OtherCharge = item.OtherCharge; s.Consignee = item.Consignor; s.Consignor = item.Consignee; s.CourierType = item.CourierType; s.DestinationLocation = item.DestinationLocation; s.CBM = item.CBM; s.Weight = item.Weight; s.Pieces = item.Pieces.ToString(); s.Discount = item.Discount; s.NetTotal = item.NetTotal; s.FAgent = item.FAgent; s.FAWBNo = item.FAWBNo; s.NCND = item.NCND; s.Department = item.Branch; s.DepartmentID = branchid; //s.CustomerID = ConsignorID; s.ConsigneeCountryID = destinationID; s.ConsignorCountryID = origincountryid; s.CollectedBy = CollectedByemp; s.ReceivedBy = recbyemp; s.UserID = 12; s.StatusTransit = false; s.InScanDate = DateTime.Now; s.CollectedByName = item.CollectedBy; s.ReceivedByName = item.ReceivedBy; s.OriginID = origincountryid; s.MovementID = coumoveid; //s.ProductTypeID = prd; //s.CustomerRateTypeID = crtd; // s.PackingCharge = item.PackingCharge; db.InScans.Add(s); db.SaveChanges(); var d = (from c in db.tempTables where c.AWBNo == item.AWBNo select c).FirstOrDefault(); db.tempTables.Remove(d); db.SaveChanges(); } ImpExp e = db.ImpExps.Find(Convert.ToInt32(Session["ImpExpID"].ToString())); e.Status = "Updated"; e.Employee = e.Employee; e.ImportDate = e.ImportDate; e.ImpExpID = e.ImpExpID; e.FName = e.FName; db.Entry(e).State = EntityState.Modified; db.SaveChanges(); TempData["Message"] = "Data Updated successfully."; return(RedirectToAction("Index", "Home")); }