public override void Save() { try { int Id = 0; foreach (var item in grdLister.Rows) { Id = item.Cells["Id"].Value.ToInt(); if (Id > 0) { objMaster.GetByPrimaryKey(Id); objMaster.Edit(); objMaster.Current.PerMinJourneyCharges = item.Cells[COLS.PerMinJourneyCharges].Value.ToDecimal(); objMaster.CheckDataValidation = false; objMaster.Save(); objMaster.Clear(); } } } 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 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 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); } } }