コード例 #1
0
        private decimal CalculateFlatRate(int income)
        {
            var tax = new FlatRate();

            tax.Calculate(income);
            return(tax.Result);
        }
コード例 #2
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            if (originComboBox.SelectedItem == null || destinationComboBox.SelectedItem == null)
            {
                MessageBox.Show("Not enough infomation");
                return;
            }

            if (costTextBox.Text.Count() == 0)
            {
                MessageBox.Show("You need fill cost field first");
                return;
            }

            string   originShortName      = originComboBox.SelectedItem.ToString();
            string   destinationShortName = destinationComboBox.SelectedItem.ToString();
            string   costString           = costTextBox.Text;
            RateType rateType;
            Int32    rateCost;

            Enum.TryParse <RateType>(typeComboBox.SelectedItem.ToString(), out rateType);
            Int32.TryParse(costTextBox.Text, out rateCost);

            if (_originalOriginDestinationShortName != _originalOriginRegionShortName || _originalOriginDestinationShortName != destinationShortName)
            {
                if (_carrier.HasRate(originShortName, destinationShortName))
                {
                    MessageBox.Show("Each carrier can only have one rate per lane");
                    return;
                }
            }

            try
            {
                Rate newRate = null;
                switch (rateType)
                {
                case RateType.Flat:
                    newRate = new FlatRate(originShortName, destinationShortName, rateCost);
                    break;

                case RateType.Increase:
                    newRate = new IncreaseRate(originShortName, destinationShortName, rateCost);
                    break;
                }

                _carrier.RemoveRate(_rateToEdit);
                _carrier.AddRate(newRate);
                Carrier.Store.SaveToDisk();
                MessageBox.Show("Rate has been saved");
                this.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
コード例 #3
0
        private void demoDataButton_Click(object sender, EventArgs e)
        {
            _regionStore.Erase();
            _carrierStore.Erase();

            Carrier MasterCarrier = new Carrier {
                SCAC = "MAST", Name = "Master Carrier"
            };
            Carrier SlaveCarrier = new Carrier {
                SCAC = "SLAV", Name = "Slave Carrier"
            };

            Region OriginCityRegion = new RMA.Model.Region {
                XAxis = 0, YAxis = 0, ShortName = "OC", Description = "Origin City"
            };
            Region DestinationCityRegion = new RMA.Model.Region {
                XAxis = 13, YAxis = 13, ShortName = "DC", Description = "Destination City"
            };
            Region ChaosLandRegion = new RMA.Model.Region {
                XAxis = 100, YAxis = 100, ShortName = "CL", Description = "Chaos Land"
            };
            Region VoidWorldRegion = new RMA.Model.Region {
                XAxis = -100, YAxis = -100, ShortName = "VW", Description = "Void World"
            };

            FlatRate     flatRateForMasterCarrier     = new FlatRate(OriginCityRegion, DestinationCityRegion, 1000);
            IncreaseRate increaseRateForMasterCarrier = new IncreaseRate(DestinationCityRegion, ChaosLandRegion, 10);

            FlatRate     flatRateForSlaveCarrier     = new FlatRate(OriginCityRegion, DestinationCityRegion, 800);
            IncreaseRate increaseRateForSlaveCarrier = new IncreaseRate(DestinationCityRegion, ChaosLandRegion, 9);

            MasterCarrier.AddRate(flatRateForMasterCarrier);
            MasterCarrier.AddRate(increaseRateForMasterCarrier);
            SlaveCarrier.AddRate(flatRateForSlaveCarrier);
            SlaveCarrier.AddRate(increaseRateForMasterCarrier);

            MasterCarrier.Insert();
            SlaveCarrier.Insert();

            OriginCityRegion.Insert();
            DestinationCityRegion.Insert();
            ChaosLandRegion.Insert();
            VoidWorldRegion.Insert();

            _carrierStore.SaveToDisk();
            _regionStore.SaveToDisk();

            MessageBox.Show("load demo data task complete");
        }
コード例 #4
0
        public void BonusPlanToUserCommunityInsert()
        {
            using (SqlConnection Connection = new SqlConnection(ConfigurationManager.AppSettings["WebApplication"]))
            {
                using (SqlCommand Command = new SqlCommand("BonusPlan.BonusPlanToUserCommunityInsert", Connection))
                {
                    Command.CommandType    = CommandType.StoredProcedure;
                    Command.CommandTimeout = 600;

                    Command.Parameters.Add("@BonusPlanID", SqlDbType.Int);
                    Command.Parameters["@BonusPlanID"].Value = BonusPlanID.NullIfEmpty();

                    Command.Parameters.Add("@EmployeeID", SqlDbType.Int);
                    Command.Parameters["@EmployeeID"].Value = EmployeeID.NullIfEmpty();

                    Command.Parameters.Add("@CommunityNumber", SqlDbType.VarChar);
                    Command.Parameters["@CommunityNumber"].Value = CommunityNumber.NullIfEmpty();

                    Command.Parameters.Add("@Percentage", SqlDbType.VarChar);
                    Command.Parameters["@Percentage"].Value = Percentage.NullIfEmpty();

                    Command.Parameters.Add("@FlatRate", SqlDbType.VarChar);
                    Command.Parameters["@FlatRate"].Value = FlatRate.NullIfEmpty();

                    Command.Parameters.Add("@BeginDt", SqlDbType.VarChar);
                    Command.Parameters["@BeginDt"].Value = BeginDt.NullIfEmpty();

                    Command.Parameters.Add("@EndDt", SqlDbType.VarChar);
                    Command.Parameters["@EndDt"].Value = EndDt.NullIfEmpty();

                    Command.Parameters.Add("@RollforwardFlg", SqlDbType.Int);
                    Command.Parameters["@RollforwardFlg"].Value = RollforwardFlg.NullIfEmpty("0");

                    Command.Parameters.Add("@CreateBy", SqlDbType.VarChar);
                    Command.Parameters["@CreateBy"].Value = Audit.CreateBy.NullIfEmpty();

                    Connection.Open();
                    Command.ExecuteNonQuery();
                }
            }
        }
コード例 #5
0
 public FlatRateCalculator(IOptions <TaxOptionSet> options)
 {
     flatRate = options.Value.FlatRate;
 }
コード例 #6
0
 public FlatRateCondition(FlatRate rateConditions)
 {
     _rateConditions = rateConditions;
 }
コード例 #7
0
 public FlatRateCalculator(FlatRate rateConditions)
 {
     _rateConditions = rateConditions;
 }