示例#1
0
        public double applyCostingRulesOnTransaction(RuntimeData trans, double billedWeight)
        {
            if (costingRules == null)
            {
                initializeRules();
            }
            List <CostingRule> RulesApplied = costingRules.Where(x => x.startW <= billedWeight && x.endW >= billedWeight).ToList();

            RulesApplied = rulesSelector(RulesApplied.Cast <IRule>().ToList(), trans).Cast <CostingRule>().ToList();
            decimal price = 0;

            RulesApplied.ForEach((x) =>
            {
                if (!x.applyRule(trans, billedWeight))
                {
                    CostingRule RulesApplied2 = costingRules.Where(u => u.endW < x.startW).OrderByDescending(z => z.endW).FirstOrDefault();
                    if (RulesApplied2 != null)
                    {
                        trans.FrAmount += (decimal)applyCostingRulesOnTransaction(trans, RulesApplied2.endW);
                    }
                }

                if (price < trans.FrAmount)
                {
                    price = (decimal)trans.FrAmount;
                }
            });
            return(Convert.ToDouble(price));
        }
示例#2
0
        private void EditRule_Click(object sender, RoutedEventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            if (CostingRuleGrid.Visibility == Visibility.Visible && CostingRuleGrid.SelectedItem != null)
            {
                if (MessageBox.Show("Do you Want edit this Rule", "", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    CostingRule dcr = (CostingRule)CostingRuleGrid.SelectedItem;
                    AddRule     win = new AddRule(dcr.Id);
                    win.Closed += win_Closed;
                    win.Show();
                    CostingRuleGrid.SelectedItem = null;
                }
            }
            if (ServiceRuleGrid.Visibility == Visibility.Visible && ServiceRuleGrid.SelectedItem != null)
            {
                if (MessageBox.Show("Do you Want edit this Rule", "", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    ServiceRule    dcr = (ServiceRule)ServiceRuleGrid.SelectedItem;
                    AddServiceRule win = new AddServiceRule(dcr.Id);
                    win.Closed += win_Closed;
                    win.Show();
                    ServiceRuleGrid.SelectedItem = null;
                }
            }
            db.SubmitChanges();
        }
示例#3
0
 private void CostingRuleGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.EditAction == DataGridEditAction.Commit)
     {
         double rate;
         if (double.TryParse((e.EditingElement as TextBox).Text, out rate))
         {
             try
             {
                 BillingDataDataContext db       = new BillingDataDataContext();
                 CostingRule            origRule = e.Row.Item as CostingRule;
                 Rule newRule = db.Rules.SingleOrDefault(x => x.ID == origRule.Id);
                 if (newRule == null)
                 {
                     MessageBox.Show("Unable to find this rule in database....", "Error");
                     e.Cancel = true;
                     return;
                 }
                 JavaScriptSerializer jss = new JavaScriptSerializer();
                 CostingRule          crr = jss.Deserialize <CostingRule>(newRule.Properties);
                 if (e.Column.Header.ToString() == "Non-Dox (Rs)")
                 {
                     crr.ndoxAmount = rate;
                 }
                 if (e.Column.Header.ToString() == "Dox (Rs)")
                 {
                     crr.doxAmount = rate;
                 }
                 newRule.Properties = jss.Serialize(crr);
                 db.SubmitChanges();
             }
             catch (Exception)
             {
                 MessageBox.Show("Unable to save data....", "Error");
                 e.Cancel = true;
                 return;
             }
         }
         else
         {
             MessageBox.Show("Invalid Input.. ", "Error");
             e.Cancel = true;
         }
     }
 }
示例#4
0
        public CostingRule(string propertyString)
            : base()
        {
            CostingRule rule = (new JavaScriptSerializer()).Deserialize <CostingRule>(propertyString);

            this.CityList     = rule.CityList;
            this.doxAmount    = rule.doxAmount;
            this.dStartValue  = rule.dStartValue;
            this.endW         = rule.endW;
            this.ndoxAmount   = rule.ndoxAmount;
            this.ndStartValue = rule.ndStartValue;
            this.ServiceList  = rule.ServiceList;
            this.startW       = rule.startW;
            this.StateList    = rule.StateList;
            this.stepWeight   = rule.stepWeight;
            this.type         = rule.type;
            this.ZoneList     = rule.ZoneList;
        }
 public AddRule(int ruleId)
     : this()
 {
     this.isUpdate = true;
     db            = new BillingDataDataContext();
     rule          = db.Rules.SingleOrDefault(x => x.ID == ruleId);
     if (rule == null)
     {
         MessageBox.Show("Invalid Rule.");
         return;
     }
     InitializeComponent();
     this.Title                 = "Update Rule " + ruleId.ToString();
     this.AddFilter.Data        = Geometry.Parse(@"F1M2,12.942C2,12.942 10.226,15.241 10.226,15.241 10.226,15.241 8.275,17.071 8.275,17.071 9.288,17.922 10.917,18.786 12.32,18.786 15.074,18.786 17.386,16.824 18.039,14.171 18.039,14.171 21.987,15.222 21.987,15.222 20.891,19.693 16.996,23 12.357,23 9.771,23 7.076,21.618 5.308,19.934 5.308,19.934 3.454,21.671 3.454,21.671 3.454,21.671 2,12.942 2,12.942z M11.643,2C14.229,2 16.924,3.382 18.692,5.066 18.692,5.066 20.546,3.329 20.546,3.329 20.546,3.329 22,12.058 22,12.058 22,12.058 13.774,9.759 13.774,9.759 13.774,9.759 15.725,7.929 15.725,7.929 14.712,7.078 13.083,6.214 11.68,6.214 8.926,6.214 6.614,8.176 5.961,10.829 5.961,10.829 2.013,9.778 2.013,9.778 3.109,5.307 7.004,2 11.643,2z");
     this.AddFilter.Height      = 18;
     this.AddFilter.Width       = 18;
     this.AddRuleButtonBox.Text = " Update Rule";
     RuleCR             = (new JavaScriptSerializer()).Deserialize <CostingRule>(rule.Properties);
     FromWeightBox.Text = RuleCR.startW.ToString();
     ToWeightBox.Text   = RuleCR.endW.ToString();
     DOXAmountBox.Text  = RuleCR.doxAmount.ToString();
     NDoxAmountBox.Text = RuleCR.ndoxAmount.ToString();
     AddRule.setFormList(RuleCR, ServiceTwinBox, ZoneTwinBox, StateTwinBox, CitiesTwinBox, ServiceGroupTwinBox);
     if (RuleCR.type == 'R')
     {
         RangeTypeRadio.IsChecked      = true;
         StepTypeRadio.IsChecked       = false;
         MultiplierTypeRadio.IsChecked = false;
     }
     if (RuleCR.type == 'S')
     {
         RangeTypeRadio.IsChecked      = false;
         StepTypeRadio.IsChecked       = true;
         MultiplierTypeRadio.IsChecked = false;
     }
     if (RuleCR.type == 'M')
     {
         RangeTypeRadio.IsChecked      = false;
         StepTypeRadio.IsChecked       = false;
         MultiplierTypeRadio.IsChecked = true;
     }
     StepBlockBox.Text = RuleCR.stepWeight.ToString();
 }
 public AddRule(Quotation quoation)
     : this()
 {
     this.quoation                          = quoation;
     RuleCR                                 = new CostingRule();
     db                                     = new BillingDataDataContext();
     currentGridObj.Visibility              = Visibility.Visible;
     ServiceTwinBox.AllListSource           = (DataSources.ServicesCopy);
     ServiceTwinBox.SelectedListSource      = new List <Service>();
     ServiceTwinBox.DisplayValuePath        = "NameAndCode";
     ZoneTwinBox.AllListSource              = (DataSources.ZoneCopy);
     ZoneTwinBox.SelectedListSource         = new List <ZONE>();
     ZoneTwinBox.DisplayValuePath           = "NameAndCode";
     StateTwinBox.AllListSource             = DataSources.StateCopy;
     StateTwinBox.SelectedListSource        = new List <State>();
     StateTwinBox.DisplayValuePath          = "NameAndCode";
     CitiesTwinBox.AllListSource            = DataSources.CityCopy;
     CitiesTwinBox.SelectedListSource       = new List <City>();
     CitiesTwinBox.DisplayValuePath         = "NameAndCode";
     ServiceGroupTwinBox.AllListSource      = DataSources.ServiceGroupCopy;
     ServiceGroupTwinBox.DisplayValuePath   = "GroupName";
     ServiceGroupTwinBox.SelectedListSource = new List <ServiceGroup>();
 }