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; }
private void FormLoad(object sender, EventArgs e) { 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.EditValueChanged += lkpDestination_EditValueChanged; 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 += lkpPackageType_EditValueChanged; lkpService.LookupPopup = new ServiceTypePopup("name.Equals(@0) OR name.Equals(@1) OR name.Equals(@2)", "ECO", "ONS", "SUPER ECONOMI"); 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))", s, "ECO", "ONS", "SUPER ECONOMI"); lkpService.FieldLabel = "Service Type"; lkpService.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; lkpService.EditValueChanged += lkpServiceType_EditValueChanged; tbxName.FieldLabel = "Shipper Name"; tbxName.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxAddress.FieldLabel = "Shipper Address"; tbxAddress.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxPhone.FieldLabel = "Shipper Phone"; tbxPhone.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) }; tbxTtlGrossWeight.EditMask = "###,##0.0"; tbxTtlGrossWeight.FieldLabel = "Total Weight"; tbxTtlGrossWeight.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxTtlChargeable.EditMask = "###,##0.0"; tbxTtlChargeable.FieldLabel = "Chargeable Weight"; tbxTtlChargeable.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxTtlChargeable.EditValueChanged += lkpDestination_EditValueChanged; tbxDiscount.EditMask = "#0.0%%"; tbxName.CharacterCasing = CharacterCasing.Upper; tbxAddress.CharacterCasing = CharacterCasing.Upper; tbxPhone.CharacterCasing = CharacterCasing.Upper; tbxConsigneeName.CharacterCasing = CharacterCasing.Upper; tbxConsigneeAddress.CharacterCasing = CharacterCasing.Upper; tbxConsigneePhone.CharacterCasing = CharacterCasing.Upper; tbxRef.CharacterCasing = CharacterCasing.Upper; tbxNote.CharacterCasing = CharacterCasing.Upper; tbxNatureOfGood.CharacterCasing = CharacterCasing.Upper; tbxName.MaxLength = 100; tbxAddress.MaxLength = 254; tbxPhone.MaxLength = 50; tbxConsigneeName.MaxLength = 100; tbxConsigneeAddress.MaxLength = 254; tbxConsigneePhone.MaxLength = 50; tbxRef.MaxLength = 50; tbxNote.MaxLength = 100; tbxNatureOfGood.MaxLength = 50; tbxTtlGrossWeight.TextChanged += GrossWeightChange; FormTrackingStatus = EnumTrackingStatus.FranchiseDataEntry; cbxMobilePoint.Click += (s, o) => { if (cbxMobilePoint.Checked) { tbxEmailPoint.Focus(); tbxEmailPoint.Enabled = true; } else { tbxEmailPoint.Clear(); tbxEmailPoint.Enabled = false; } }; btnSave.Click += (s, o) => { if (Save()) { NoResi = tbxResi.Text; form.Close(); } }; btnSavePrint.Click += (s, o) => { if (string.IsNullOrEmpty(BaseControl.PrinterSetting.InkJet)) { MessageBox.Show("Lakukan setting ulang printer di menu Preference/Printer Preference"); return; } if (Save()) { NoResi = tbxResi.Text; var printout = new EConnotePrintout { DataSource = GetPrintDataSource() }; # if (DEBUG) printout.PrintPreview(); # else printout.Print(); # endif
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); } tbxNo.Leave += tbxShipmentNo_Leave; lkpDestination.LookupPopup = new CityPopup(); lkpDestination.AutoCompleteDataManager = new CityDataManager(); 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) }; 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 PackageTypeDataManager(); 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) }; lkpService.LookupPopup = new ServiceTypePopup(); lkpService.AutoCompleteDataManager = new ServiceTypeDataManager(); lkpService.AutoCompleteDisplayFormater = model => ((ServiceTypeModel)model).Name; lkpService.AutoCompleteWhereExpression = (s, p) => p.SetWhereExpression("name.StartsWith(@0)", s); lkpService.FieldLabel = "Service Type"; lkpService.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; lkpPayment.LookupPopup = new PaymentMethodPopup("name.Equals(@0) OR name.Equals(@1)", "COLLECT ", "CREDIT"); lkpPayment.AutoCompleteDataManager = new PaymentMethodDataManager(); lkpPayment.AutoCompleteDisplayFormater = model => ((PaymentMethodModel)model).Name; lkpPayment.AutoCompleteWhereExpression = (s, p) => p.SetWhereExpression("name.StartsWith(@0) AND (name.Equals(@1) OR name.Equals(@2))", s, "COLLECT", "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) }; tbxTtlGrossWeight.EditMask = "###,##0.0"; tbxTtlGrossWeight.FieldLabel = "Total Weight"; tbxTtlGrossWeight.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxTtlChargeable.EditMask = "###,##0.0"; tbxTtlChargeable.FieldLabel = "Chargeable Weight"; tbxTtlChargeable.ValidationRules = new[] { new ComponentValidationRule(EnumComponentValidationRule.Mandatory) }; tbxDiscount.EditMask = "#0.0%%"; tbxOther.EditMask = "##,###,##0.00"; tbxGoodsValue.EditMask = "##,###,##0.00"; tbxInsurance.EditMask = "##,###,##0.00"; 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; tbxDiscount.TextChanged += (o, args) => RefreshTariff(); FormTrackingStatus = EnumTrackingStatus.CorporateDateEntry; 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(); }; lkpDestination.EditValueChanged += lkpDestination_EditValueChanged; lkpPackage.EditValueChanged += lkpPackageType_EditValueChanged; lkpService.EditValueChanged += lkpServiceType_EditValueChanged; tbxOther.EditValueChanged += txtOtherFee_EditValueChanged; tbxGoodsValue.EditValueChanged += txtGoodsValue_EditValueChanged; tbxTtlPiece.EditValueChanged += txtTotalPiece_EditValueChanged; tbxTtlGrossWeight.EditValueChanged += txtTotalWeight_EditValueChanged; tbxTtlChargeable.EditValueChanged += txtChargeable_EditValueChanged; tbxDiscount.EditValueChanged += tbxDiscount_EditValueChanged; using (var branchDm = new BranchDataManager()) { var branch = branchDm.GetFirst <BranchModel>(WhereTerm.Default(BaseControl.BranchId, "id")); MaximumBranchDiscount = branch.MaxDiscount > 0 ? branch.MaxDiscount : 0; } rbPod.Visible = true; rbPod_Void.Enabled = false; rbPod_Void.ItemClick += Void; }