Example #1
0
        private void Login(object sender, EventArgs e)
        {
            UseWaitCursor = true;
            if (tbxUsername.Text == "")
            {
                MessageBox.Show(Resources.empty_username, Resources.title_information);
                UseWaitCursor = false;
                return;
            }

            var dm   = new CorporateUserDataManager();
            var user = dm.Login(tbxUsername.Text, tbxPassword.Text, BaseControl.CorporateId);

            if (user != null)
            {
                var em        = new CustomerDataManager();
                var corporate = em.GetFirst <CustomerModel>(WhereTerm.Default(user.CorporateId, "id", EnumSqlOperator.Equals));

                if (corporate != null)
                {
                    BaseControl.UserId        = user.Id;
                    BaseControl.UserLogin     = user.UserName;
                    BaseControl.CorporateName = corporate.Name;
                    BaseControl.BranchId      = corporate.BranchId;

                    var branch =
                        new BranchDataManager().GetFirst <BranchModel>(WhereTerm.Default(corporate.BranchId, "id",
                                                                                         EnumSqlOperator.Equals));

                    BaseControl.CityId     = branch.CityId;
                    BaseControl.BranchCode = branch.Code;

                    var city =
                        new CityDataManager().GetFirst <CityModel>(WhereTerm.Default(branch.CityId, "id",
                                                                                     EnumSqlOperator.Equals));

                    BaseControl.CityName  = city.Name;
                    BaseControl.CountryId = city.CountryId;

                    var country =
                        new CountryDataManager().GetFirst <CountryModel>(WhereTerm.Default(city.CountryId, "id",
                                                                                           EnumSqlOperator.Equals));

                    BaseControl.CountryName = country.Name;

                    Authorization.SetCorporateUserId(BaseControl.UserId);

                    Dispose();
                }
                else
                {
                    MessageBox.Show(string.Format("{0} {1}", Resources.franchise_account_not_found, Resources.contact_it_support), Resources.title_information);
                }
            }
            else
            {
                MessageBox.Show(Resources.invalid_login, Resources.title_login_failed);
            }
            UseWaitCursor = false;
        }
Example #2
0
        public void Delete(string value)
        {
            var dataQuery = new CountryDataModel();

            dataQuery.CountryId = int.Parse(value);
            CountryDataManager.Delete(dataQuery, SessionVariables.RequestProfile);
        }
Example #3
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();
        }
Example #4
0
        public CountryDataModel GetById(string value)
        {
            var dataQuery = new CountryDataModel();

            dataQuery.CountryId = int.Parse(value);
            var result = CountryDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1);

            return(result[0]);
        }
Example #5
0
 static public Address GetAddress(int id)
 {
     try
     {
         Address address = AddressDataManager.GetAddress(id);
         address.Country = CountryDataManager.GetCountry(address.Country.Id);
         address.City    = CityDataManager.GetCity(address.City.Id);
         address.Street  = StreetDataManager.GetStreet(address.Street.Id);
         return(address);
     }
     catch (Exception ex)
     {
         _logger.Debug($"Failed to get adddress {id}.", ex);
         throw;
     }
 }
Example #6
0
        // GET api/summary/GetList
        public IEnumerable <CountryDataModel> GetList(string value, string value1)
        {
            var settingCategory = value1;
            var searchString    = value;

            var dictionaryObject = JsonConvert.DeserializeObject <Dictionary <string, string> >(searchString);

            // save search filter parameters in user preference
            if (dictionaryObject != null)
            {
                foreach (var searchFilterColumnName in dictionaryObject.Keys)
                {
                    var searchFilterValue = dictionaryObject[searchFilterColumnName];
                    PerferenceUtility.UpdateUserPreference(settingCategory, searchFilterColumnName, dictionaryObject[searchFilterColumnName]);
                }
            }

            var dataQuery = JsonConvert.DeserializeObject <CountryDataModel>(searchString);

            return(CountryDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile));
        }
Example #7
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;
        }
Example #8
0
 public void Update([FromBody] CountryDataModel data)
 {
     CountryDataManager.Update(data, SessionVariables.RequestProfile);
 }