Пример #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;
        }
Пример #2
0
        public void Delete(string value)
        {
            var dataQuery = new CityDataModel();

            dataQuery.CityId = int.Parse(value);
            CityDataManager.Delete(dataQuery, SessionVariables.RequestProfile);
        }
Пример #3
0
        private static Address insertNewCityAndNewStreet(Address address)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    if (address.City != null && !(address.City.Id > 0))
                    {
                        address.City.Country.Id = address.Country.Id;
                        address.City.Id         = CityDataManager.InsertCity(address.City);
                    }
                    if (address.Street != null && !(address.Street.Id > 0))
                    {
                        address.Street.City.Id = address.City.Id;
                        address.Street.Id      = StreetDataManager.InsertStreet(address.Street);
                    }

                    scope.Complete();
                    return(address);
                }
            }
            catch (Exception ex)
            {
                _logger.Debug("Failed to save city/street", ex);
                throw;
            }
        }
Пример #4
0
        private string HeaderDotMetrix(int hal)
        {
            string print = File.ReadAllText(@"ShipmentListPrint.txt");

            // ReSharper disable InconsistentNaming
            var customer_name  = "-";
            var dest_city      = "-";
            var payment_method = "-";
            var from_date      = "-";
            var to_date        = "-";

            // ReSharper restore InconsistentNaming


            customer_name = BaseControl.CorporateName;

            if (tbxDestination.Value != null)
            {
                dest_city =
                    new CityDataManager().GetFirst <CityModel>(WhereTerm.Default((int)tbxDestination.Value, "id",
                                                                                 EnumSqlOperator.Equals)).Name;
            }

            from_date = tbxFrom.Value.ToString("dd-MM-yyyy");
            to_date   = tbxTo.Value.ToString("dd-MM-yyyy");

            print = print.Replace("{CUSTOMER_NAME}", customer_name);
            print = print.Replace("{DEST_CITY}", dest_city);
            print = print.Replace("{PAYMENT_METHOD}", payment_method);
            print = print.Replace("{FROM_DATE}", from_date);
            print = print.Replace("{TO_DATE}", to_date);
            print = print.Replace("{HAL}", hal.ToString("#").PadLeft(3, ' ') + string.Format("{0}", (char)15));

            return(print);
        }
Пример #5
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();
        }
Пример #6
0
        public CityDataModel GetById(string value)
        {
            var dataQuery = new CityDataModel();

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

            return(result[0]);
        }
Пример #7
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;
     }
 }
Пример #8
0
        // GET api/summary/GetList
        public IEnumerable <CityDataModel> 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 <CityDataModel>(searchString);

            return(CityDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile));
        }
Пример #9
0
        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();
            }
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <CityInfoResponse> GetCityInfo()
        {
            var cityDataManager = new CityDataManager();

            return(cityDataManager.GetCityInfo());
        }
Пример #11
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;
        }
Пример #12
0
        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);
        }
Пример #13
0
 public void Update([FromBody] CityDataModel data)
 {
     CityDataManager.Update(data, SessionVariables.RequestProfile);
 }