protected override void btnSave_Click(object sender, EventArgs e)
 {
     if (ValidateInput())
     {
         string result = string.Empty;
         GuaranteeFeeConfiguration configuration = GetConfigurationInfo();
         if (_isUpdating)
         {
             configuration.id = SelectedItemID;
             result           = _business.Update(configuration);
         }
         else
         {
             configuration.id = IDGenerator.NewId <GuaranteeFeeConfiguration>(true);
             result           = _business.Insert(configuration);
         }
         if (string.IsNullOrEmpty(result))
         {
             ChangeViewStatus(false);
             DataBind();
         }
         else
         {
             MessageBox.Show(result, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void LoadConfigurationInfo(GuaranteeFeeConfiguration configuration)
 {
     if (configuration != null)
     {
         tbValueFrom.Text    = configuration.value_from.ToString("N0");
         tbValueTo.Text      = configuration.value_to != Constants.MAX_MONEY_VALUE ? configuration.value_to.ToString("N0") : string.Empty;
         tbGuaranteeFee.Text = configuration.guarantee_fee.ToString("N0");
     }
 }
예제 #3
0
        public static GuaranteeFeeConfiguration ConvertToGuaranteeFee(TGuaranteeFee tfee)
        {
            GuaranteeFeeConfiguration price = new GuaranteeFeeConfiguration();

            price.id            = tfee.Id;
            price.guarantee_fee = decimal.Parse(tfee.Fee.ToString());
            price.value_from    = decimal.Parse(tfee.ValueFrom.ToString());
            price.value_to      = decimal.Parse(tfee.ValueTo.ToString());

            return(price);
        }
예제 #4
0
        public static TGuaranteeFee ConvertToTGuaranteeFee(GuaranteeFeeConfiguration fee)
        {
            TGuaranteeFee tprice = new TGuaranteeFee();

            tprice.Id        = fee.id;
            tprice.Fee       = double.Parse(fee.guarantee_fee.ToString());
            tprice.ValueFrom = double.Parse(fee.value_from.ToString());
            tprice.ValueTo   = double.Parse(fee.value_to.ToString());

            return(tprice);
        }
 private void dgvItemsList_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvItemsList.SelectedRows.Count > 0)
     {
         btnUpdate.Enabled = true;
         btnDelete.Enabled = true;
         GuaranteeFeeConfiguration configuration = _business.Get(SelectedItemID);
         LoadConfigurationInfo(configuration);
     }
     else
     {
         btnUpdate.Enabled = false;
         btnDelete.Enabled = false;
     }
 }
        private decimal CalculateTotalCost(double weight, string size, decimal value, int quantity)
        {
            decimal totalCost = 0;

            try
            {
                decimal transportPrice = 0;
                decimal guaranteeFee   = 0;

                TransportPriceConfiguration transportPriceConfig = _transportPriceConfigurations.FirstOrDefault(e =>
                                                                                                                e.size.Equals(size) &&
                                                                                                                weight >= e.weight_from &&
                                                                                                                weight < e.weight_to);
                if (transportPriceConfig != null)
                {
                    transportPrice      = transportPriceConfig.transport_price;
                    tbTotalCost.Enabled = false;

                    // Only load GuaranteeFeeConfiguration if TransportPriceConfiguration is available
                    GuaranteeFeeConfiguration guaranteeFeeConfig = _guaranteeFeeConfigurations.FirstOrDefault(e =>
                                                                                                              value >= e.value_from &&
                                                                                                              value < e.value_to);
                    if (guaranteeFeeConfig != null)
                    {
                        guaranteeFee = guaranteeFeeConfig.guarantee_fee;
                    }
                }
                else
                {
                    tbTotalCost.Enabled = true;
                }

                totalCost = transportPrice * quantity + guaranteeFee;
            }
            catch (FormatException)
            {
                // Ignore FormatException
                AppLogger.logDebug(this.ToString(), "The FormatException was thrown but intentionally ignored.");
            }
            catch (Exception ex)
            {
                AppLogger.logError(this.ToString(), "Error occur when calculating total cost.", ex);
            }
            return(totalCost);
        }