public void InitializeConstructors() { this.Load += new EventHandler(frmFares_Load); objMaster = new FareBO(); this.SetProperties((INavigation)objMaster); if (AppVars.objPolicyConfiguration != null) { HasOffPeakRate = AppVars.objPolicyConfiguration.EnablePeakOffPeakFares.ToBool(); } //if (AppVars.objPolicyConfiguration.EnableZoneWiseFares.ToBool()) //{ // this.pg_FixFareList.Item.Visibility = ElementVisibility.Collapsed; //} FormatFaresPDAOtherDetailGrid(); FillCombos(); OnNew(); }
public frmJourneyTime() { InitializeComponent(); objMaster = new FareBO(); FormatGrid(); this.SetProperties((INavigation)objMaster); this.Load += new EventHandler(frmJourneyTime_Load); this.KeyDown += new KeyEventHandler(frmJourneyTime_KeyDown); this.btnSave.Click += new EventHandler(btnSave_Click); this.btnExit1.Click += new EventHandler(btnExit1_Click); }
public frmCopyCompanyFares() { InitializeComponent(); FormatFaresGrid(); objMaster = new FareBO(); this.SetProperties((INavigation)objMaster); grdCompany.EnableFiltering = true; grdCompany.CellFormatting += new CellFormattingEventHandler(grdFares_CellFormatting); this.Load += new EventHandler(frmShowcompanyCopyFare_Load); worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); this.chkAllCompany.CheckedChanged += new EventHandler(chkAllCompany_CheckedChanged); }
public void CopyCompanyFares(int CompanyId) { try { // int VehicleTypeId = cVehicleTypeId; if (SaveFares == false) { int FareId = 0; var Query = General.GetObject <Fare>(c => c.CompanyId == CompanyId); if (CompanyId == 0 && Vechileid > 0) { var Query2 = General.GetObject <Fare>(c => c.VehicleTypeId == Vechileid); if (Query2 != null) { FareId = Query2.Id; } } if (Query != null) { FareId = Query.Id; } var FareList = (from a in General.GetQueryable <Fare_ChargesDetail>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, OriginLocationTypeId = a.OriginLocationTypeId, DestinationLocationTypeId = a.DestinationLocationTypeId, OriginId = a.OriginId, DestinationId = a.DestinationId, FromAddress = a.FromAddress, ToAddress = a.ToAddress, Rate = a.Rate, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); ChargesDetail.Clear(); foreach (var item in FareList) { decimal Rate = item.Rate.ToDecimal(); if (ApplyAdditionOrSubtractionOnFareRates) { decimal Amount = 0.00m; decimal PercentValue = numPercent.Value.ToDecimal(); if (rbtnAdd.IsChecked) { Amount = ((Rate * PercentValue) / 100); Rate = (Rate + Amount); } else { Amount = ((Rate * PercentValue) / 100); Rate = (Rate - Amount); } } ChargesDetail.Add(new Fare_ChargesDetail { Id = item.Id, FareId = item.FareId, OriginLocationTypeId = item.OriginLocationTypeId, DestinationLocationTypeId = item.DestinationLocationTypeId, OriginId = item.OriginId, DestinationId = item.DestinationId, FromAddress = item.FromAddress, ToAddress = item.ToAddress, Rate = Rate, NightTimeRate = item.NightTimeRate }); } var OtherChargesList = (from a in General.GetQueryable <Fare_OtherCharge>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); OtherCharge.Clear(); foreach (var item in OtherChargesList) { OtherCharge.Add(new Fare_OtherCharge { Id = item.Id, FareId = item.FareId, FromMile = item.FromMile, ToMile = item.ToMile, Rate = item.Rate, FromStartTime = item.FromStartTime, TillStartTime = item.TillStartTime, FromEndTime = item.TillEndTime, TillEndTime = item.TillEndTime, PeakTimeRate = item.PeakTimeRate, OffPeakTimeRate = item.OffPeakTimeRate, NightTimeRate = item.NightTimeRate }); } var PDAMeterList = (from a in General.GetQueryable <Fare_PDAMeter>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); PDAMeter.Clear(); foreach (var item in PDAMeterList) { PDAMeter.Add(new Fare_PDAMeter { Id = item.Id, FareId = item.FareId, FromMile = item.FromMile, ToMile = item.ToMile, Rate = item.Rate, FromStartTime = item.FromStartTime, TillStartTime = item.TillStartTime, FromEndTime = item.FromEndTime, TillEndTime = item.TillEndTime, PeakTimeRate = item.PeakTimeRate, OffPeakTimeRate = item.OffPeakTimeRate, NightTimeRate = item.NightTimeRate }); } var ZoneWisePricingList = (from a in General.GetQueryable <Fare_ZoneWisePricing>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromZoneId = a.FromZoneId, ToZoneId = a.ToZoneId, Price = a.Price, }).ToList(); ZoneWisePricing.Clear(); foreach (var item in ZoneWisePricingList) { ZoneWisePricing.Add(new Fare_ZoneWisePricing { Id = item.Id, FareId = item.FareId, FromZoneId = item.FromZoneId, ToZoneId = item.ToZoneId, Price = item.Price }); } var AirportAndStationList = (from a in General.GetQueryable <Gen_Company_AgentCommission>(c => c.FareId == FareId) select new { Id = a.Id, a.CompanyId, FareId = a.FareId, LocationId = a.LocationId, LocationTypeId = a.LocationTypeId, CommissionPercent = a.CommissionPercent, CommissionAmount = a.CommissionAmount, CommissionOnPercent = a.CommissionOnPercent, DayWise = a.DayWise, NightWise = a.NightWise, VehicleTypeId = a.VehicleTypeId, CompanyPrice = a.CompanyPrice, DriverPrice = a.DriverPrice, CustomerPrice = a.CustomerPrice }).ToList(); CompanyAirportandStation.Clear(); foreach (var item in AirportAndStationList) { CompanyAirportandStation.Add(new Gen_Company_AgentCommission { Id = item.Id, FareId = item.FareId, CompanyId = item.CompanyId, LocationId = item.LocationId, LocationTypeId = item.LocationTypeId, CommissionAmount = item.CommissionAmount, CommissionOnPercent = item.CommissionOnPercent, CommissionPercent = item.CommissionPercent, CompanyPrice = item.CompanyPrice, CustomerPrice = item.CustomerPrice, DayWise = item.DayWise, NightWise = item.NightWise, DriverPrice = item.DriverPrice, VehicleTypeId = item.VehicleTypeId }); } } else { var CompanyList = (from a in General.GetQueryable <Gen_Company>(null) select new { Id = a.Id, CompanyName = a.CompanyName }).ToList(); var queryy = CompanyList.Where(item => selectlist.Contains(item.Id)); foreach (var item in queryy) { if (objMaster.PrimaryKeyValue == null) { objMaster.New(); } else { objMaster.Edit(); } objMaster.Current.VehicleTypeId = Vechileid; // objMaster.Current.VehicleTypeId = VehicleTypeId.ToInt(); objMaster.Current.CompanyId = item.Id; objMaster.Current.IsCompanyWise = true; objMaster.Current.AddOn = DateTime.Now; objMaster.Current.AddBy = AppVars.LoginObj.LuserId.ToIntorNull(); objMaster.Current.StartRate = numStartRate.Value; objMaster.Current.StartRateValidMiles = numStartRateValidMiles.Value; string[] skipProperties = { "Gen_Company", "Gen_Location", "Gen_Location1", "Gen_LocationType", "Gen_LocationType1", "Fare", "Gen_Zone1", "Gen_Zone", "Fare_ZoneWisePricing1","Fare_ZoneWisePricing", "Fleet_VehicleType" }; IList <Fare_ChargesDetail> savedList = objMaster.Current.Fare_ChargesDetails; List <Fare_ChargesDetail> ListDetail = (from a in ChargesDetail select new Fare_ChargesDetail { Id = a.Id, FareId = objMaster.Current.Id, OriginLocationTypeId = a.OriginLocationTypeId, DestinationLocationTypeId = a.OriginLocationTypeId, OriginId = a.OriginId, DestinationId = a.DestinationId, FromAddress = a.FromAddress, ToAddress = a.ToAddress, Rate = a.Rate, NightTimeRate = a.NightTimeRate }).ToList(); Utils.General.SyncChildCollection(ref savedList, ref ListDetail, "Id", skipProperties); // OtherCharge IList <Fare_OtherCharge> savedList2 = objMaster.Current.Fare_OtherCharges; List <Fare_OtherCharge> listofOtherDetail = (from a in OtherCharge select new Fare_OtherCharge { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0 }).ToList(); Utils.General.SyncChildCollection(ref savedList2, ref listofOtherDetail, "Id", skipProperties); // PDA METER IList <Fare_PDAMeter> savedList3 = objMaster.Current.Fare_PDAMeters; List <Fare_PDAMeter> listofpdaOtherDetail = (from a in PDAMeter select new Fare_PDAMeter { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0 }).ToList(); Utils.General.SyncChildCollection(ref savedList3, ref listofpdaOtherDetail, "Id", skipProperties); IList <Fare_ZoneWisePricing> saveList4 = objMaster.Current.Fare_ZoneWisePricings; List <Fare_ZoneWisePricing> listofDetail4 = (from a in ZoneWisePricing select new Fare_ZoneWisePricing { Id = a.Id, FareId = a.FareId, FromZoneId = a.FromZoneId, ToZoneId = a.ToZoneId, Price = a.Price, }).ToList(); Utils.General.SyncChildCollection(ref saveList4, ref listofDetail4, "Id", skipProperties); //HP IList <Gen_Company_AgentCommission> saveList5 = objMaster.Current.Gen_Company_AgentCommissions; List <Gen_Company_AgentCommission> listofDetail5 = (from a in CompanyAirportandStation select new Gen_Company_AgentCommission { Id = a.Id, FareId = a.FareId, LocationId = a.LocationId, LocationTypeId = a.LocationTypeId, CommissionPercent = a.CommissionPercent, CommissionAmount = a.CommissionAmount, CommissionOnPercent = a.CommissionOnPercent, DayWise = a.DayWise, NightWise = a.NightWise, VehicleTypeId = a.VehicleTypeId, CompanyPrice = a.CompanyPrice, DriverPrice = a.DriverPrice, CustomerPrice = a.CustomerPrice, CompanyId = item.Id }).ToList(); Utils.General.SyncChildCollection(ref saveList5, ref listofDetail5, "Id", skipProperties); // objMaster.Save(); objMaster.Clear(); objMaster = new FareBO(); FaresSaved(item.Id); } } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }
public override void Save() { FareBO objFareMaster = null; try { int vehicleId = 0; string oldFrom = string.Empty; string vehicle = string.Empty; string from = string.Empty; string to = string.Empty; decimal fares = 0.00m; int?fromLocId = null; int?toLocId = null; int?fromLocTypeId = null; int?toLocTypeId = null; List <Fleet_VehicleType> listOfVehicle = AppVars.BLData.GetQueryable <Fleet_VehicleType>(null).ToList(); List <Gen_Location> listOfLocations = General.GetQueryable <Gen_Location>(null).ToList(); LocationBO objLocationMaster = null; int recordNo = 0; foreach (var row in grdFixFares.Rows) { if (!string.IsNullOrEmpty(row.Cells[COLS.VehicleName].Value.ToStr())) { vehicle = row.Cells[COLS.VehicleName].Value.ToStr(); } from = row.Cells[COLS.From].Value.ToStr().ToUpper(); oldFrom = from; if (!string.IsNullOrEmpty(row.Cells[COLS.To].Value.ToStr().ToUpper())) { to = row.Cells[COLS.To].Value.ToStr().ToUpper(); } if (row.Cells[COLS.Fare].Value.ToStr().StartsWith("£")) { fares = row.Cells[COLS.Fare].Value.ToStr().Substring(1).ToDecimal(); } else { fares = row.Cells[COLS.Fare].Value.ToDecimal(); } if (string.IsNullOrEmpty(from)) { continue; } if (string.IsNullOrEmpty(to)) { } vehicleId = listOfVehicle.FirstOrDefault(c => c.VehicleType.ToLower().Trim() == vehicle).DefaultIfEmpty().Id; if (vehicleId == 0) { // row.Cells[COLS.Status].Value = "Required : Vehicle"; continue; } Gen_Location objLoc = listOfLocations.FirstOrDefault(c => ((c.LocationName.ToUpper().Trim() + " " + c.PostCode.ToUpper()) == from) || (c.PostCode == from)); if (objLoc == null) { objLocationMaster = new LocationBO(); try { objLocationMaster.New(); from = General.GetPostCodeMatch(from); if (string.IsNullOrEmpty(from)) { } objLocationMaster.Current.LocationName = from; objLocationMaster.Current.PostCode = from; objLocationMaster.Current.LocationTypeId = Enums.LOCATION_TYPES.POSTCODE; objLocationMaster.Save(); } catch (Exception ex) { if (objLocationMaster.Errors.Count > 0) { ENUtils.ShowMessage(objLocationMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } break; } objLoc = objLocationMaster.Current; listOfLocations.Add(objLoc); } fromLocId = objLoc.Id; fromLocTypeId = objLoc.LocationTypeId; objLoc = listOfLocations.FirstOrDefault(c => ((c.LocationName.ToUpper().Trim() + " " + c.PostCode.ToUpper()) == to) || (c.PostCode == to)); if (objLoc == null) { objLocationMaster = new LocationBO(); try { objLocationMaster.New(); to = General.GetPostCodeMatch(to); // to = General.GetPostCodeMatch(to); if (to.Contains(' ') == false) { } objLocationMaster.Current.LocationName = to; objLocationMaster.Current.PostCode = to; objLocationMaster.Current.LocationTypeId = Enums.LOCATION_TYPES.POSTCODE; objLocationMaster.Save(); } catch (Exception ex) { if (objLocationMaster.Errors.Count > 0) { ENUtils.ShowMessage(objLocationMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } break; } objLoc = objLocationMaster.Current; listOfLocations.Add(objLoc); } toLocId = objLoc.Id; toLocTypeId = objLoc.LocationTypeId; if (recordNo == 0) { objFareMaster = new FareBO(); int fareId = General.GetObject <Fare>(c => c.VehicleTypeId == vehicleId).DefaultIfEmpty().Id; if (fareId > 0) { objFareMaster.GetByPrimaryKey(fareId); } else { objFareMaster.New(); } objFareMaster.Current.VehicleTypeId = vehicleId; objFareMaster.Current.IsCompanyWise = false; } objFareMaster.Current.Fare_ChargesDetails.Add(new Fare_ChargesDetail { OriginId = fromLocId, DestinationId = toLocId, OriginLocationTypeId = fromLocTypeId, DestinationLocationTypeId = toLocTypeId, Rate = fares }); recordNo++; } objFareMaster.Save(); } catch (Exception ex) { if (objFareMaster.Errors.Count > 0) { ENUtils.ShowMessage(objFareMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }
public void CopyCompanyFares(int SubCompanyId) { try { // int VehicleTypeId = cVehicleTypeId; //if (SaveFares == false) { int FareId = 0; var Query = General.GetObject <Fare>(c => (c.SubCompanyId == SubCompanyId) && (c.VehicleTypeId == Vechileid)); //if (SubCompanyId == 0 && Vechileid > 0) //{ // var Query2 = General.GetObject<Fare>(c => c.VehicleTypeId == Vechileid); // if (Query2 != null) // { // FareId = Query2.Id; // } //} if (Query != null) { FareId = Query.Id; } if (optApplyAll.IsChecked || optOnlyFixedFares.IsChecked) { var FareList = (from a in General.GetQueryable <Fare_ChargesDetail>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, OriginLocationTypeId = a.OriginLocationTypeId, DestinationLocationTypeId = a.DestinationLocationTypeId, OriginId = a.OriginId, DestinationId = a.DestinationId, FromAddress = a.FromAddress, ToAddress = a.ToAddress, Rate = a.Rate, a.CompanyRate, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); ChargesDetail.Clear(); foreach (var item in FareList) { decimal Rate = item.Rate.ToDecimal(); decimal CompanyRate = item.CompanyRate.ToDecimal(); if (numPercent.Value.ToDecimal() > 0) { decimal Amount = 0.00m; decimal PercentValue = numPercent.Value.ToDecimal(); if (rbtnAdd.IsChecked) { Amount = ((Rate * PercentValue) / 100); Rate = (Rate + Amount); } else { Amount = ((Rate * PercentValue) / 100); Rate = (Rate - Amount); } if (rbtnAdd.IsChecked) { Amount = ((CompanyRate * PercentValue) / 100); CompanyRate = (CompanyRate + Amount); } else { Amount = ((CompanyRate * PercentValue) / 100); CompanyRate = (CompanyRate - Amount); } } ChargesDetail.Add(new Fare_ChargesDetail { Id = item.Id, FareId = item.FareId, OriginLocationTypeId = item.OriginLocationTypeId, DestinationLocationTypeId = item.DestinationLocationTypeId, OriginId = item.OriginId, DestinationId = item.DestinationId, FromAddress = item.FromAddress, ToAddress = item.ToAddress, Rate = Rate, NightTimeRate = item.NightTimeRate, CompanyRate = CompanyRate }); } } else { ChargesDetail.Clear(); } if (optApplyAll.IsChecked || optOnlyMileage.IsChecked) { var OtherChargesList = (from a in General.GetQueryable <Fare_OtherCharge>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, a.CompanyRate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); OtherCharge.Clear(); foreach (var item in OtherChargesList) { decimal Rate = item.Rate.ToDecimal(); decimal CompanyRate = item.CompanyRate.ToDecimal(); if (numPercent.Value.ToDecimal() > 0) { decimal Amount = 0.00m; decimal PercentValue = numPercent.Value.ToDecimal(); if (rbtnAdd.IsChecked) { Amount = ((Rate * PercentValue) / 100); Rate = (Rate + Amount); } else { Amount = ((Rate * PercentValue) / 100); Rate = (Rate - Amount); } if (rbtnAdd.IsChecked) { Amount = ((CompanyRate * PercentValue) / 100); CompanyRate = (CompanyRate + Amount); } else { Amount = ((CompanyRate * PercentValue) / 100); CompanyRate = (CompanyRate - Amount); } } OtherCharge.Add(new Fare_OtherCharge { Id = item.Id, FareId = item.FareId, FromMile = item.FromMile, ToMile = item.ToMile, Rate = Rate, CompanyRate = CompanyRate, FromStartTime = item.FromStartTime, TillStartTime = item.TillStartTime, FromEndTime = item.TillEndTime, TillEndTime = item.TillEndTime, PeakTimeRate = item.PeakTimeRate, OffPeakTimeRate = item.OffPeakTimeRate, NightTimeRate = item.NightTimeRate }); } } else { OtherCharge.Clear(); } if (optApplyAll.IsChecked || optOnlyPlottoPlot.IsChecked) { var ZoneWisePricingList = (from a in General.GetQueryable <Fare_ZoneWisePricing>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromZoneId = a.FromZoneId, ToZoneId = a.ToZoneId, Rate = a.Price, a.CompanyRate }).ToList(); ZoneWisePricing.Clear(); foreach (var item in ZoneWisePricingList) { decimal Rate = item.Rate.ToDecimal(); decimal CompanyRate = item.CompanyRate.ToDecimal(); if (numPercent.Value.ToDecimal() > 0) { decimal Amount = 0.00m; decimal PercentValue = numPercent.Value.ToDecimal(); if (rbtnAdd.IsChecked) { Amount = ((Rate * PercentValue) / 100); Rate = (Rate + Amount); } else { Amount = ((Rate * PercentValue) / 100); Rate = (Rate - Amount); } if (rbtnAdd.IsChecked) { Amount = ((CompanyRate * PercentValue) / 100); CompanyRate = (CompanyRate + Amount); } else { Amount = ((CompanyRate * PercentValue) / 100); CompanyRate = (CompanyRate - Amount); } } ZoneWisePricing.Add(new Fare_ZoneWisePricing { Id = item.Id, FareId = item.FareId, FromZoneId = item.FromZoneId, ToZoneId = item.ToZoneId, Price = Rate, CompanyRate = CompanyRate }); } } else { ZoneWisePricing.Clear(); } var CompanyList = (from a in General.GetQueryable <Gen_SubCompany>(null) select new { Id = a.Id, CompanyName = a.CompanyName }).ToList(); var queryy = CompanyList.Where(item => selectlist.Contains(item.Id)); foreach (var item in queryy) { if (objMaster.PrimaryKeyValue == null) { objMaster.New(); } objMaster.Current.VehicleTypeId = Vechileid; objMaster.Current.SubCompanyId = item.Id; objMaster.Current.AddOn = DateTime.Now; objMaster.Current.AddBy = AppVars.LoginObj.LuserId.ToIntorNull(); string[] skipProperties = { "Gen_Company", "Gen_Location", "Gen_Location1", "Gen_LocationType", "Gen_LocationType1", "Fare", "Gen_Zone1", "Gen_Zone", "Fare_ZoneWisePricing1","Fare_ZoneWisePricing", "Fleet_VehicleType" }; if (optApplyAll.IsChecked || optOnlyFixedFares.IsChecked) { IList <Fare_ChargesDetail> savedList = objMaster.Current.Fare_ChargesDetails; List <Fare_ChargesDetail> ListDetail = (from a in ChargesDetail select new Fare_ChargesDetail { Id = a.Id, FareId = objMaster.Current.Id, OriginLocationTypeId = a.OriginLocationTypeId, DestinationLocationTypeId = a.OriginLocationTypeId, OriginId = a.OriginId, DestinationId = a.DestinationId, FromAddress = a.FromAddress, ToAddress = a.ToAddress, Rate = a.Rate, CompanyRate = a.CompanyRate, NightTimeRate = a.NightTimeRate }).ToList(); Utils.General.SyncChildCollection(ref savedList, ref ListDetail, "Id", skipProperties); } // OtherCharge if (optApplyAll.IsChecked || optOnlyMileage.IsChecked) { IList <Fare_OtherCharge> savedList2 = objMaster.Current.Fare_OtherCharges; List <Fare_OtherCharge> listofOtherDetail = (from a in OtherCharge select new Fare_OtherCharge { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, CompanyRate = a.CompanyRate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0 }).ToList(); Utils.General.SyncChildCollection(ref savedList2, ref listofOtherDetail, "Id", skipProperties); } if (optApplyAll.IsChecked || optOnlyPlottoPlot.IsChecked) { IList <Fare_ZoneWisePricing> saveList4 = objMaster.Current.Fare_ZoneWisePricings; List <Fare_ZoneWisePricing> listofDetail4 = (from a in ZoneWisePricing select new Fare_ZoneWisePricing { Id = a.Id, FareId = a.FareId, FromZoneId = a.FromZoneId, ToZoneId = a.ToZoneId, Price = a.Price, CompanyRate = a.CompanyRate, }).ToList(); Utils.General.SyncChildCollection(ref saveList4, ref listofDetail4, "Id", skipProperties); } objMaster.Save(); objMaster.Clear(); objMaster = new FareBO(); FaresSaved(item.Id); } } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }
public void CopyCompanyFares(int?CompanyId) { try { // int VehicleTypeId = cVehicleTypeId; if (SaveFares == false) { int FareId = 0; var Faresquery = General.GetQueryable <Fare>(c => (c.VehicleTypeId == VehicleId) && (c.CompanyId == null)).ToList(); //&& (CompanyId== null || c.CompanyId == CompanyId)).ToList(); FaresList.Clear(); ChargesDetail.Clear(); OtherCharge.Clear(); PDAMeter.Clear(); ZoneWisePricing.Clear(); CompanyAirportandStation.Clear(); foreach (var objFare in Faresquery) { FaresList.Add(new Fare { Id = objFare.Id, CompanyId = objFare.CompanyId, IsCompanyWise = objFare.IsCompanyWise, IsDayWise = objFare.IsDayWise, IsVehicleWise = objFare.IsVehicleWise, FromDateTime = objFare.FromDateTime, TillDateTime = objFare.TillDateTime, FromDayName = objFare.FromDayName, TillDayName = objFare.TillDayName, TillSpecialDate = objFare.TillSpecialDate, SpecialDayName = objFare.SpecialDayName, DayValue = objFare.DayValue, StartRate = objFare.StartRate, StartRateValidMiles = objFare.StartRateValidMiles, SubCompanyId = objFare.SubCompanyId, FromSpecialDate = objFare.FromSpecialDate });; //var Query = General.GetObject<Fare>(c => c.CompanyId == CompanyId); //if (CompanyId == 0 && Vechileid > 0) //{ // var Query2 = General.GetObject<Fare>(c => c.VehicleTypeId == Vechileid); // if (Query2 != null) // { // FareId = Query2.Id; // } //} //if (Query != null) //{ // FareId = Query.Id; //} FareId = objFare.Id; var FareList = (from a in General.GetQueryable <Fare_ChargesDetail>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, OriginLocationTypeId = a.OriginLocationTypeId, DestinationLocationTypeId = a.DestinationLocationTypeId, OriginId = a.OriginId, DestinationId = a.DestinationId, FromAddress = a.FromAddress, ToAddress = a.ToAddress, Rate = a.Rate, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); foreach (var item in FareList) { decimal Rate = item.Rate.ToDecimal(); if (ApplyAdditionOrSubtractionOnFareRates) { decimal Amount = 0.00m; decimal PercentValue = numPercent.Value.ToDecimal(); if (rbtnAdd.IsChecked) { Amount = ((Rate * PercentValue) / 100); Rate = (Rate + Amount); } else { Amount = ((Rate * PercentValue) / 100); Rate = (Rate - Amount); } } ChargesDetail.Add(new Fare_ChargesDetail { Id = item.Id, FareId = item.FareId, OriginLocationTypeId = item.OriginLocationTypeId, DestinationLocationTypeId = item.DestinationLocationTypeId, OriginId = item.OriginId, DestinationId = item.DestinationId, FromAddress = item.FromAddress, ToAddress = item.ToAddress, Rate = Rate, NightTimeRate = item.NightTimeRate }); } var OtherChargesList = (from a in General.GetQueryable <Fare_OtherCharge>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); foreach (var item in OtherChargesList) { OtherCharge.Add(new Fare_OtherCharge { Id = item.Id, FareId = item.FareId, FromMile = item.FromMile, ToMile = item.ToMile, Rate = item.Rate, FromStartTime = item.FromStartTime, TillStartTime = item.TillStartTime, FromEndTime = item.TillEndTime, TillEndTime = item.TillEndTime, PeakTimeRate = item.PeakTimeRate, OffPeakTimeRate = item.OffPeakTimeRate, NightTimeRate = item.NightTimeRate }); } var PDAMeterList = (from a in General.GetQueryable <Fare_PDAMeter>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0, }).ToList(); foreach (var item in PDAMeterList) { PDAMeter.Add(new Fare_PDAMeter { Id = item.Id, FareId = item.FareId, FromMile = item.FromMile, ToMile = item.ToMile, Rate = item.Rate, FromStartTime = item.FromStartTime, TillStartTime = item.TillStartTime, FromEndTime = item.FromEndTime, TillEndTime = item.TillEndTime, PeakTimeRate = item.PeakTimeRate, OffPeakTimeRate = item.OffPeakTimeRate, NightTimeRate = item.NightTimeRate }); } var ZoneWisePricingList = (from a in General.GetQueryable <Fare_ZoneWisePricing>(c => c.FareId == FareId) select new { Id = a.Id, FareId = a.FareId, FromZoneId = a.FromZoneId, ToZoneId = a.ToZoneId, Price = a.Price, }).ToList(); foreach (var item in ZoneWisePricingList) { ZoneWisePricing.Add(new Fare_ZoneWisePricing { Id = item.Id, FareId = item.FareId, FromZoneId = item.FromZoneId, ToZoneId = item.ToZoneId, Price = item.Price }); } var AirportAndStationList = (from a in General.GetQueryable <Gen_Company_AgentCommission>(c => c.FareId == FareId) select new { Id = a.Id, a.CompanyId, FareId = a.FareId, LocationId = a.LocationId, LocationTypeId = a.LocationTypeId, CommissionPercent = a.CommissionPercent, CommissionAmount = a.CommissionAmount, CommissionOnPercent = a.CommissionOnPercent, DayWise = a.DayWise, NightWise = a.NightWise, VehicleTypeId = a.VehicleTypeId, CompanyPrice = a.CompanyPrice, DriverPrice = a.DriverPrice, CustomerPrice = a.CustomerPrice }).ToList(); foreach (var item in AirportAndStationList) { CompanyAirportandStation.Add(new Gen_Company_AgentCommission { Id = item.Id, FareId = item.FareId, CompanyId = item.CompanyId, LocationId = item.LocationId, LocationTypeId = item.LocationTypeId, CommissionAmount = item.CommissionAmount, CommissionOnPercent = item.CommissionOnPercent, CommissionPercent = item.CommissionPercent, CompanyPrice = item.CompanyPrice, CustomerPrice = item.CustomerPrice, DayWise = item.DayWise, NightWise = item.NightWise, DriverPrice = item.DriverPrice, VehicleTypeId = item.VehicleTypeId }); } } } else { //var CompanyList = (from a in General.GetQueryable<Gen_Company>(null) // select new // { // Id = a.Id, // CompanyName = a.CompanyName // }).ToList(); foreach (var itemFare in FaresList) { //var queryy = CompanyList.Where(item => selectlist.Contains(item.Id)); //foreach (var item in queryy) foreach (var item in objCopyFares) { if (!item.MileageSettings && !item.FixedFares) { continue; } // var list = General.GetQueryable<Fare>(c => (c.VehicleTypeId == VehicleId) && (c.SubCompanyId == SubCompanyId) && ((CompanyId == null || c.CompanyId == CompanyId))).ToList(); //var query = General.GetObject<Fare>(c => (c.VehicleTypeId == VehicleId) && ( c.CompanyId == item.Id)); //if (query != null) //{ // objMaster.GetByPrimaryKey(query.Id); //} if (objMaster.PrimaryKeyValue == null) { objMaster.New(); } else { objMaster.Edit(); } objMaster.Current.VehicleTypeId = VehicleId; // objMaster.Current.VehicleTypeId = VehicleTypeId.ToInt(); objMaster.Current.CompanyId = item.Id; objMaster.Current.IsCompanyWise = true; objMaster.Current.AddOn = DateTime.Now; objMaster.Current.AddBy = AppVars.LoginObj.LuserId.ToIntorNull(); // objMaster.SaveWithoutValidatingVehicleType = true; objMaster.Current.FromDayName = itemFare.FromDayName; objMaster.Current.TillDayName = itemFare.TillDayName; objMaster.Current.FromDateTime = itemFare.FromDateTime; objMaster.Current.TillDateTime = itemFare.TillDateTime; objMaster.Current.StartRate = itemFare.StartRate; objMaster.Current.StartRateValidMiles = itemFare.StartRateValidMiles; objMaster.Current.IsCompanyWise = itemFare.IsCompanyWise; objMaster.Current.SubCompanyId = itemFare.SubCompanyId; objMaster.Current.DayValue = itemFare.DayValue; objMaster.Current.SpecialDayName = itemFare.SpecialDayName; objMaster.Current.IsDayWise = itemFare.IsDayWise; //IsSpecialDay;//item.Cells[COLS_OTHERDETAILS.IsSpecialDay].Value.ToBool(); objMaster.Current.FromSpecialDate = itemFare.FromSpecialDate; // //dtpFromSpecialTime.Value != null ? FromSpecialDate.ToDateorNull() + dtpFromSpecialTime.Value.ToDateTimeorNull().Value.TimeOfDay : FromSpecialDate.ToDateorNull(); objMaster.Current.TillSpecialDate = itemFare.TillSpecialDate; // //dtpTillSpecialTime.Value != null ? TillSpecialDate.ToDateorNull() + dtpTillSpecialTime.Value.ToDateTimeorNull().Value.TimeOfDay : TillSpecialDate.ToDateorNull(); // //objMaster.Current.StartRate = numStartRate.Value; //objMaster.Current.StartRateValidMiles = numStartRateValidMiles.Value; string[] skipProperties = { "Gen_Company", "Gen_Location", "Gen_Location1", "Gen_LocationType", "Gen_LocationType1", "Fare", "Gen_Zone1", "Gen_Zone", "Fare_ZoneWisePricing1","Fare_ZoneWisePricing", "Fleet_VehicleType" }; if (item.FixedFares) { IList <Fare_ChargesDetail> savedList = objMaster.Current.Fare_ChargesDetails; List <Fare_ChargesDetail> ListDetail = (from a in ChargesDetail.Where(c => c.FareId == itemFare.Id) select new Fare_ChargesDetail { Id = a.Id, FareId = objMaster.Current.Id, OriginLocationTypeId = a.OriginLocationTypeId, DestinationLocationTypeId = a.OriginLocationTypeId, OriginId = a.OriginId, DestinationId = a.DestinationId, FromAddress = a.FromAddress, ToAddress = a.ToAddress, Rate = a.Rate, NightTimeRate = a.NightTimeRate }).ToList(); Utils.General.SyncChildCollection(ref savedList, ref ListDetail, "Id", skipProperties); } // OtherCharge if (item.MileageSettings) { IList <Fare_OtherCharge> savedList2 = objMaster.Current.Fare_OtherCharges; List <Fare_OtherCharge> listofOtherDetail = (from a in OtherCharge.Where(c => c.FareId == itemFare.Id) select new Fare_OtherCharge { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0 }).ToList(); Utils.General.SyncChildCollection(ref savedList2, ref listofOtherDetail, "Id", skipProperties); // PDA METER IList <Fare_PDAMeter> savedList3 = objMaster.Current.Fare_PDAMeters; List <Fare_PDAMeter> listofpdaOtherDetail = (from a in PDAMeter.Where(c => c.FareId == itemFare.Id) select new Fare_PDAMeter { Id = a.Id, FareId = a.FareId, FromMile = a.FromMile, ToMile = a.ToMile, Rate = a.Rate, FromStartTime = HasOffPeakRate ? a.FromStartTime : null, TillStartTime = HasOffPeakRate ? a.TillStartTime : null, FromEndTime = HasOffPeakRate ? a.FromEndTime : null, TillEndTime = HasOffPeakRate ? a.TillEndTime : null, PeakTimeRate = HasOffPeakRate ? a.PeakTimeRate : 0, OffPeakTimeRate = HasOffPeakRate ? a.OffPeakTimeRate : 0, NightTimeRate = HasOffPeakRate ? a.NightTimeRate : 0 }).ToList(); Utils.General.SyncChildCollection(ref savedList3, ref listofpdaOtherDetail, "Id", skipProperties); } //IList<Fare_ZoneWisePricing> saveList4 = objMaster.Current.Fare_ZoneWisePricings; //List<Fare_ZoneWisePricing> listofDetail4 = (from a in ZoneWisePricing.Where(c => c.FareId == itemFare.Id) // select new Fare_ZoneWisePricing // { // Id = a.Id, // FareId = a.FareId, // FromZoneId = a.FromZoneId, // ToZoneId = a.ToZoneId, // Price = a.Price, // }).ToList(); //Utils.General.SyncChildCollection(ref saveList4, ref listofDetail4, "Id", skipProperties); ////HP //IList<Gen_Company_AgentCommission> saveList5 = objMaster.Current.Gen_Company_AgentCommissions; //List<Gen_Company_AgentCommission> listofDetail5 = (from a in CompanyAirportandStation.Where(c=>c.FareId==itemFare.Id) // select new Gen_Company_AgentCommission // { // Id = a.Id, // FareId = a.FareId, // LocationId = a.LocationId, // LocationTypeId = a.LocationTypeId, // CommissionPercent = a.CommissionPercent, // CommissionAmount = a.CommissionAmount, // CommissionOnPercent = a.CommissionOnPercent, // DayWise = a.DayWise, // NightWise = a.NightWise, // VehicleTypeId = a.VehicleTypeId, // CompanyPrice = a.CompanyPrice, // DriverPrice = a.DriverPrice, // CustomerPrice = a.CustomerPrice, // CompanyId = item.Id // }).ToList(); //Utils.General.SyncChildCollection(ref saveList5, ref listofDetail5, "Id", skipProperties); //// objMaster.Save(); objMaster.Clear(); objMaster = new FareBO(); FaresSaved(item.Id); } } } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }