Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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;
        }