private void lkpDestination_EditValueChanged(object sender, EventArgs e) { if (CurrentModel == null) { return; } var cityDataManager = new CityDataManager(); var countryDataManager = new CountryDataManager(); var cityModel = cityDataManager.GetFirst <CityModel>(WhereTerm.Default(lkpDestination.Value ?? 0, "Id")); if (cityModel != null) { var countryModel = countryDataManager.GetFirst <CountryModel>(WhereTerm.Default(cityModel.CountryId, "Id")); if (countryModel != null) { ((ShipmentModel)CurrentModel).PricingPlanId = countryModel.PricingPlanId; } } cityDataManager.Dispose(); countryDataManager.Dispose(); RefreshTariff(); }
private void RefreshServiceType() { if (lkpDestination.Value == null) { return; } int originBranchId = 0; using (var cityDataManager = new CityDataManager()) { var originCity = cityDataManager.GetFirst <CityModel>(WhereTerm.Default(BaseControl.CityId, "id")); if (originCity != null) { originBranchId = originCity.BranchId; } } BranchCityListModel branchCityListModel; using (var branchCityListDataManager = new BranchCityListDataManager()) { branchCityListModel = branchCityListDataManager.GetFirst <BranchCityListModel>( WhereTerm.Default(originBranchId, "branch_id"), WhereTerm.Default((int)lkpDestination.Value, "city_id") ); } if (branchCityListModel != null) { lkpService.DefaultValue = new IListParameter[] { WhereTerm.Default(SERVICE_TYPE_CITY_COURIER, "Name") }; } else { RefreshTariff(); } }
protected override void LoadForm(object sender, EventArgs e) { base.LoadForm(sender, e); EnableBtnSearch = true; SearchPopup = new ShipmentPopup(); try { using (var configDm = new ConfigDataManager()) { _fixedShippingInsuranceRate = decimal.Parse(configDm.Get("FixedShippingInsuranceRate")); } } catch (Exception ex) { MessageBox.Show(@"The insurance rate setting must be correctly set in the config table (FixedShippingInsuranceRate)", @"Error!"); throw new Exception("The insurance rate setting must be correctly set in the config table (FixedShippingInsuranceRate)", ex); } lkpDestination.LookupPopup = new CityPopup(); lkpDestination.AutoCompleteDataManager = new CityServices(); lkpDestination.AutoCompleteDisplayFormater = model => ((CityModel)model).Name; lkpDestination.AutoCompleteWheretermFormater = s => new IListParameter[] { WhereTerm.Default(s, "name", EnumSqlOperator.BeginWith) }; lkpDestination.FieldLabel = "Destination City"; lkpDestination.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; lkpDestination.Leave += (s, o) => { var cityDataManager = new CityDataManager(); var countryDataManager = new CountryDataManager(); var cityModel = cityDataManager.GetFirst <CityModel>(WhereTerm.Default(lkpDestination.Value ?? 0, "Id")); if (cityModel != null) { var countryModel = countryDataManager.GetFirst <CountryModel>(WhereTerm.Default(cityModel.CountryId, "Id")); if (countryModel != null) { ((ShipmentModel)CurrentModel).PricingPlanId = countryModel.PricingPlanId; } } cityDataManager.Dispose(); countryDataManager.Dispose(); RefreshServiceType(); }; lkpConsignee.LookupPopup = new ConsigneePopup(); lkpConsignee.AutoCompleteDataManager = new ConsigneeDataManager(); lkpConsignee.AutoCompleteDisplayFormater = model => ((ConsigneeModel)model).Name; lkpConsignee.AutoCompleteWheretermFormater = s => new IListParameter[] { WhereTerm.Default(BaseControl.CorporateId, "corporate_id", EnumSqlOperator.Equals), WhereTerm.Default(s, "name", EnumSqlOperator.BeginWith) }; lkpConsignee.Leave += AutoPopulateConsigneeDetail; lkpPackage.LookupPopup = new PackageTypePopup(); lkpPackage.AutoCompleteDataManager = new PackageTypeServices(); lkpPackage.AutoCompleteDisplayFormater = model => ((PackageTypeModel)model).Name; lkpPackage.AutoCompleteWheretermFormater = s => new IListParameter[] { WhereTerm.Default(s, "name", EnumSqlOperator.BeginWith) }; lkpPackage.FieldLabel = "Package Type"; lkpPackage.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; lkpPackage.EditValueChanged += (s, o) => RefreshTariff(); lkpPackage.Leave += (s, o) => NoServiceMessage(); lkpService.LookupPopup = new ServiceTypePopup("name.Equals(@0) OR name.Equals(@1) OR name.Equals(@2) OR name.Equals(@3) OR name.Equals(@4) OR name.Equals(@5)", "REGULAR", "ONS", "DARAT", "CITY COURIER", "SDS", "LAUT"); lkpService.AutoCompleteDataManager = new ServiceTypeServices(); lkpService.AutoCompleteDisplayFormater = model => ((ServiceTypeModel)model).Name; lkpService.AutoCompleteWhereExpression = (s, p) => p.SetWhereExpression("name.StartsWith(@0) AND (name.Equals(@1) OR name.Equals(@2) OR name.Equals(@3) OR name.Equals(@4) OR name.Equals(@5) OR name.Equals(@6))", s, "REGULAR", "ONS", "DARAT", "CITY COURIER", "SDS", "LAUT"); lkpService.FieldLabel = "Service Type"; lkpService.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; lkpService.EditValueChanged += (s, o) => RefreshTariff(); lkpService.Leave += (s, o) => NoServiceMessage(); lkpPayment.LookupPopup = new PaymentMethodPopup("name.Equals(@0)", "CREDIT"); lkpPayment.AutoCompleteDataManager = new PaymentMethodServices(); lkpPayment.AutoCompleteDisplayFormater = model => ((PaymentMethodModel)model).Name; lkpPayment.AutoCompleteWhereExpression = (s, p) => p.SetWhereExpression("name.StartsWith(@0) AND name.Equals(@1)", s, "CREDIT"); lkpPayment.FieldLabel = "Payment Method"; lkpPayment.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxConsigneeName.FieldLabel = "Consignee Name"; tbxConsigneeName.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxConsigneeAddress.FieldLabel = "Consignee Address"; tbxConsigneeAddress.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxConsigneePhone.FieldLabel = "Consignee Phone"; tbxConsigneePhone.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxTtlPiece.EditMask = "###,##0"; tbxTtlPiece.FieldLabel = "Total Piece"; tbxTtlPiece.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxTtlPiece.EditValueChanged += (s, o) => RefreshGrandTotal(); tbxTtlGrossWeight.EditMask = "###,##0.0"; tbxTtlGrossWeight.FieldLabel = "Total Weight"; tbxTtlGrossWeight.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxTtlGrossWeight.EditValueChanged += (s, o) => RefreshGrandTotal(); tbxTtlChargeable.EditMask = "###,##0.0"; tbxTtlChargeable.FieldLabel = "Chargeable Weight"; tbxTtlChargeable.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxL.EditValueChanged += (s, o) => VolumeCalculation(); tbxW.EditValueChanged += (s, o) => VolumeCalculation(); tbxH.EditValueChanged += (s, o) => VolumeCalculation(); tbxOther.EditMask = "##,###,##0.00"; tbxOther.EditValueChanged += (s, o) => RefreshGrandTotal(); tbxGoodsValue.EditMask = "##,###,###,##0.00"; tbxGoodsValue.EditValueChanged += (s, o) => { var goodsvalue = tbxGoodsValue.Value; if (goodsvalue == 0) { tbxInsurance.Value = 0; } else { tbxInsurance.Value = Math.Round((goodsvalue * BaseControl.GoodValuesInsurance) + BaseControl.GoodValuesAdministration, 0, MidpointRounding.AwayFromZero); } RefreshGrandTotal(); }; tbxInsurance.EditMask = "##,###,###,##0.00"; tbxInsurance.EditValueChanged += (s, o) => RefreshGrandTotal(); tbxConsigneeName.CharacterCasing = CharacterCasing.Upper; tbxConsigneeAddress.CharacterCasing = CharacterCasing.Upper; tbxConsigneePhone.CharacterCasing = CharacterCasing.Upper; tbxNote.CharacterCasing = CharacterCasing.Upper; tbxNatureOfGood.CharacterCasing = CharacterCasing.Upper; tbxConsigneeName.MaxLength = 100; tbxConsigneeAddress.MaxLength = 254; tbxConsigneePhone.MaxLength = 50; tbxNote.MaxLength = 100; tbxNatureOfGood.MaxLength = 50; tbxTtlGrossWeight.TextChanged += TxtTotalWeightOnTextChanged; FormTrackingStatus = EnumTrackingStatus.CorporateDataEntry; rbLayout_Print.ItemClick += (o, args) => { var printout = new EConnotePrintout { DataSource = GetPrintDataSource() }; printout.PrintDialog(); }; rbLayout_PrintPreview.ItemClick += (o, args) => { var printout = new EConnotePrintout { DataSource = GetPrintDataSource() }; printout.PrintPreview(); }; lkpService.EditValueChanged += (s, args) => { RefreshServiceType(); if (lkpService.Text == "DARAT") { MinWeight = 10; } if (lkpService.Text == "LAUT") { MinWeight = 30; } if (tbxTtlGrossWeight.Value < MinWeight) { tbxTtlGrossWeight.SetValue(MinWeight); } }; using (var branchDm = new BranchDataManager()) { var branch = branchDm.GetFirst <BranchModel>(WhereTerm.Default(BaseControl.BranchId, "id")); MaximumBranchDiscount = branch.MaxDiscount > 0 ? branch.MaxDiscount : 0; } cbxPacking.Click += (s, o) => { var fee = ((tbxL.Value + tbxW.Value + tbxH.Value + 18) / 3) * 2000; if (cbxPacking.Checked) { tbxPacking.Value = fee; } else { tbxPacking.Value = 0; } RefreshGrandTotal(); }; rbPod.Visible = true; rbPod_Void.Enabled = false; rbPod_Void.ItemClick += Void; }
protected override ShipmentModel PopulateModel(ShipmentModel model) { model.DateProcess = tbxDate.DateTime; model.BranchId = BaseControl.BranchId; model.AutoNumber = true; model.NeedRa = cbxRa.Checked; model.CityId = BaseControl.CityId; model.CityName = BaseControl.CityName; if (lkpDestination.Value == null) { throw new BusinessException(""); } model.DestCityId = (int)lkpDestination.Value; model.DestCity = lkpDestination.Text; using (var dm = new CityDataManager()) { var city = dm.GetFirst <CityModel>(WhereTerm.Default(model.DestCityId, "id")); if (city != null) { model.DestBranchId = city.BranchId; model.DestCountryId = city.CountryId; model.DestCity = city.Name; var destBranch = new BranchDataManager().GetFirst <BranchModel>(WhereTerm.Default(city.BranchId, "id", EnumSqlOperator.Equals)); if (destBranch != null) { model.DestBranchName = destBranch.Name; } } else { model.DestBranchId = 0; model.DestCountryId = 0; } } model.CustomerId = BaseControl.CorporateId; Customer = new CustomerDataManager().GetFirst <CustomerModel>(WhereTerm.Default((int)model.CustomerId, "id")); model.CustomerName = Customer.Name; model.ShipperName = Customer.Name; model.ShipperAddress = Customer.Address; model.ShipperPhone = Customer.Phone; model.RefNumber = string.Empty; model.ConsigneeName = tbxConsigneeName.Text; model.ConsigneeAddress = tbxConsigneeAddress.Text; model.ConsigneePhone = tbxConsigneePhone.Text; if (lkpPackage.Value == null) { throw new BusinessException(""); } model.PackageTypeId = (int)lkpPackage.Value; model.PackageType = lkpPackage.Text; if (lkpService.Value == null) { throw new BusinessException(""); } model.ServiceTypeId = (int)lkpService.Value; if (lkpPayment.Value == null) { throw new BusinessException(""); } model.PaymentMethodId = (int)lkpPayment.Value; model.PaymentMethod = lkpPayment.Text; model.NatureOfGoods = tbxNatureOfGood.Text; model.Note = tbxNote.Text; model.TtlPiece = Convert.ToInt16(tbxTtlPiece.Value); model.TtlGrossWeight = tbxTtlGrossWeight.Value; model.TtlChargeableWeight = tbxTtlChargeable.Value; model.Tariff = tbxTariff.Value; model.HandlingFeeTotal = tbxHandlingFee.Value; model.TariffTotal = tbxTtlTariff.Value; model.DiscountPercent = 0; model.DiscountTotal = 0; model.TariffNet = tbxTariffNet.Value; model.PackingFee = tbxPacking.Value; model.OtherFee = tbxOther.Value; model.GoodsValue = tbxGoodsValue.Value; model.InsuranceFee = tbxInsurance.Value; model.Total = tbxGrandTotal.Value; model.SalesTypeId = 1; if (CurrentModel.Id == 0) { model.PODStatus = (int)EnumPodStatus.None; model.CreatedPc = Environment.MachineName; model.Code = new ShipmentDataManager().GenerateCorporatePODCode(model); model.TrackingStatusId = (int)EnumTrackingStatus.CorporateDataEntry; } return(model); }