void loadQuotation(Quotation qutObj)
        {
            ObservableCollection <CostingRule> cRules = new ObservableCollection <CostingRule>(qutObj.CostingRules);
            ObservableCollection <ServiceRule> sRule  = new ObservableCollection <ServiceRule>(qutObj.ServiceRules);
            ICollectionView cRuleView = CollectionViewSource.GetDefaultView(cRules);
            ICollectionView sRuleView = CollectionViewSource.GetDefaultView(sRule);

            cRuleView.GroupDescriptions.Add(new PropertyGroupDescription("serviceGroupReporting"));
            sRuleView.GroupDescriptions.Add(new PropertyGroupDescription("serviceGroupReporting"));
            cRuleView.GroupDescriptions.Add(new PropertyGroupDescription("zoneListReporting"));
            sRuleView.GroupDescriptions.Add(new PropertyGroupDescription("zoneListReporting"));
            CostingRuleGrid.DataContext = cRuleView;
            ServiceRuleGrid.DataContext = sRuleView;
        }
예제 #2
0
        public static double getCost(string clientCode, double wieght, string cityCode, string serviceCode, char dox)
        {
            BillingDataDataContext db = new BillingDataDataContext();
            Quotation qt = db.Quotations.SingleOrDefault(x => x.CLCODE == clientCode);

            if (qt == null)
            {
                return(-1);
            }
            double cost = qt.applyCostingRulesOnTransaction(wieght, cityCode, serviceCode, dox);

            cost = qt.applyServiceRulesOnTransaction(wieght, cityCode, serviceCode, dox, (decimal)cost);
            return(cost);
        }
        private void ImportRulesButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("You have selected " + CostingRuleGrid.SelectedItems.Count + " Costing Rules and " + ServiceRuleGrid.SelectedItems.Count + " Service Rules. Are you sure you want to import them? ", "Confirm", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                List <CostingRule>     costingRules = CostingRuleGrid.SelectedItems.Cast <CostingRule>().ToList();
                List <ServiceRule>     serviceRules = ServiceRuleGrid.SelectedItems.Cast <ServiceRule>().ToList();
                BillingDataDataContext db           = new BillingDataDataContext();
                Quotation quotation = db.Quotations.Single(x => x.CLCODE == clientO.CLCODE);
                foreach (CostingRule CRule in costingRules)
                {
                    int id;
                    id       = Convert.ToInt32(db.ExecuteQuery <decimal>("SELECT IDENT_CURRENT('Rule') +1;").FirstOrDefault());
                    CRule.Id = id;
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string serialized       = js.Serialize(CRule);
                    Rule   r = new Rule();
                    r.Type       = 1;
                    r.Properties = serialized;
                    r.QID        = quotation.Id;
                    r.Remark     = "Imported rule from " + client.CLNAME;
                    db.Rules.InsertOnSubmit(r);
                    db.SubmitChanges();
                }
                foreach (ServiceRule SRule in serviceRules)
                {
                    int id;
                    id       = Convert.ToInt32(db.ExecuteQuery <decimal>("SELECT IDENT_CURRENT('Rule') +1;").FirstOrDefault());
                    SRule.Id = id;

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string serialized       = js.Serialize(SRule);
                    Rule   r = new Rule();
                    r.Type       = 2;
                    r.Properties = serialized;
                    r.QID        = quotation.Id;
                    r.Remark     = "Imported rule from " + client.CLNAME;
                    db.Rules.InsertOnSubmit(r);
                    db.SubmitChanges();
                }
                MessageBox.Show("Rules imported.");
                this.Close();
            }
        }
예제 #4
0
 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>();
 }
 public AddServiceRule(Quotation quoation)
     : this()
 {
     isdone         = false;
     this.quotation = quoation;
     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>();
     PerRadio.IsChecked        = true;
     PercentageWrap.Visibility = Visibility.Visible;
 }
        private void LoadClientRules(Client client)
        {
            if (CostingRulesSource == null)
            {
                CostingRulesSource = (CollectionViewSource)FindResource("CostingRuleList");
            }
            if (serviceRulesView == null)
            {
                serviceRulesView = (CollectionViewSource)FindResource("ServiceRuleList");
            }
            BillingDataDataContext db = new BillingDataDataContext();

            qutObj = db.Quotations.SingleOrDefault(x => x.CLCODE == client.CLCODE);
            if (qutObj == null)
            {
                unLoadQuotation();
            }
            else
            {
                loadQuotation(qutObj);
            }
            CostingRuleGrid.SelectedItems.Clear();
            ServiceRuleGrid.SelectedItems.Clear();
        }
예제 #7
0
 private void LoadClientRules()
 {
     if (isInitialized == true)
     {
         if (CostingRulesSource == null)
         {
             CostingRulesSource = (CollectionViewSource)FindResource("CostingRuleList");
         }
         if (serviceRulesView == null)
         {
             serviceRulesView = (CollectionViewSource)FindResource("ServiceRuleList");
         }
         BillingDataDataContext db = new BillingDataDataContext();
         qutObj = db.Quotations.SingleOrDefault(x => x.CLCODE == ((Client)ClientCombo.SelectedItem).CLCODE);
         if (qutObj == null)
         {
             unLoadQuotation();
         }
         else
         {
             loadQuotation(qutObj);
         }
     }
 }