public W_Supplier() { InitializeComponent(); Title = "TSmatch: выбор поставщика"; List <Spl> items = new List <Spl>(); Docs doc = Docs.getDoc(Decl.SUPPLIERS); for (int i = doc.i0; i <= doc.il; i++) { Supl s = new Supl(i); if (s == null || string.IsNullOrWhiteSpace(s.Name) || string.IsNullOrWhiteSpace(s.City)) { continue; } items.Add(new Spl(s.Name, Lib.ToInt(s.Index), s.City, s.Street, s.Url)); suppliers.Add(s); } Spl oldSupl = items.Find(x => x.SuplName == MainWindow.SuplName); if (oldSupl == null) { Msg.F("W_Supplier: No Selected SuplName"); } int ind = items.IndexOf(oldSupl); items[ind].Flag = true; log.Info("Supplier.Count=" + suppliers.Count + "\tInitial Supplier =\"" + oldSupl.SuplName + "\""); items.Sort(); Suppliers.ItemsSource = items; }
private void elmGroups_SelectionChanged(object sender, SelectionChangedEventArgs e) { gr g = (gr)elm_groups.SelectedValue; if (g == null) return; currentGroup = model.elmGroups.Find(x => x.Mat == g.mat && x.Prf == g.prf); SuplName = currentGroup.SupplierName; Supl supl = new Supl(currentGroup.SupplierName); Supl_CS_Mat_Prf.Text = SuplName + "\t" + currentGroup.CompSetName; string str = "Адрес: "; if (!string.IsNullOrEmpty(supl.Index)) str += supl.Index + ", "; str += supl.City + ", "; if (str.Length > 20) str += "\n"; str += supl.Street + "\nтел." + supl.Telephone; Supl_CS.Text = str; //--2017.07.26 не вполне работает Hyperlink- нет вызова сайта при клике. Пока оставил так.. Supl_URL.Inlines.Clear(); Run myURL = new Run(supl.Url); Hyperlink hyperl = new Hyperlink(myURL); Supl_URL.Inlines.Add(hyperl); //-- double p = 0, w = 0, v = 0; foreach (var gr in model.elmGroups) { if (gr.SupplierName != currentGroup.SupplierName) continue; w += gr.totalWeight; v += gr.totalVolume; p += gr.totalPrice; } TotalSupl_weight_volume.Text = String.Format("Общий вес= {0:N1} кг, объем = {1:N1} м3", w, v); string sP = string.Format("{0:N2}", p); TotalSupl_price.Text = "Цена по этому поставщику " + sP + " руб"; MWmsg("MainWindow msg Group selection"); elm_groups.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal , new NextPrimeDelegate(HighLighting)); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { var gr = model.elmGroups[listBox1.SelectedIndex]; if (gr.totalPrice == 0) { label_supl.Text = ""; label_cs.Text = ""; label_suplPrice.Text = ""; } else { string suplName = gr.SupplierName; Supl supl = new Supl(suplName); label_supl.Text = supl.getSupplierStr(); label_cs.Text = gr.CompSetName; double suplPrice = 0.0; foreach (var grp in model.elmGroups) { if (grp.SupplierName == suplName) { suplPrice += grp.totalPrice; } } label_suplPrice.Text = string.Format("Всего по поставщику {0:N0} руб", suplPrice); } ts.HighlightClear(); model.Highlight(model.elmGroups[listBox1.SelectedIndex]); }
// 27/3/2017 пока - for unit test purpases only public Rule(string str, Supl supplier = null, CmpSet cs = null) { text = str; synonyms = RuleSynParse(str); ruleDP = new DP(str); CompSet = cs; Supplier = supplier; }
public void CheckAll() { Docs toc = Docs.getDoc(); //-- Check TSmach.xlsx/Suppliers consystancy Docs SupList = Docs.getDoc(Decl.SUPPLIERS); for (int i = SupList.i0; i <= SupList.il; i++) { Supl s = new Supl(i); int nCompSets = SupList.Body.Int(i, Decl.SUPL_LISTCOUNT); for (int n = 0; n < nCompSets; n++) { string csName = SupList.Body.Strng(i, Decl.SUPL_LISTCOUNT + n + 1); CS cs = null; try { cs = new CS(csName, s); } catch { } var ruleLst = Rule.Rule.getList(s.Name); string msg = string.Format("PriceList \"{0}\" " + " not awalable from Supplier \"{1}\"", csName, s.Name); if (ruleLst.Count == 0) { msg += ", and no Rule for him"; } else { msg += string.Format(", however, available {0} for him", ruleLst.Count); } log.Info(msg); if (cs == null) { continue; } cs.doc.Close(); } } return; //-- check toc and close open price-lists for (int i = toc.i0; i <= toc.il; i++) { string type = toc.Body.Strng(i, Decl.DOC_TYPE); if (!type.Contains("Comp")) { continue; } string doc_name = toc.Body.Strng(i, Decl.DOC_NAME); Docs doc = Docs.getDoc(doc_name, fatal: false); if (doc == null) { continue; } doc.Close(); } }
public double RuleRedundencyPerCent = 0.0; //коэффициент избыточности, требуемый запас по данному материалу/профилю/Правилу public Rule(Docs doc, int i) { name = (string)doc.Body[i, Decl.RULE_NAME]; type = (string)doc.Body[i, Decl.RULE_TYPE]; text = Lib.ToLat((string)doc.Body[i, Decl.RULE_RULE]); synonyms = RuleSynParse(text); ruleDP = new DP(text); // template for identification string csName = (string)doc.Body[i, Decl.RULE_COMPSETNAME]; string suplName = (string)doc.Body[i, Decl.RULE_SUPPLIERNAME]; Supplier = new Suppliers.Supplier(suplName); CompSet = new CmpSet(csName, Supplier); }
public void UT_PriceGr_Msg() { // Assign boot.Init(); Rule.Rule rule = new Rule.Rule(); rule.sSupl = "СтальХолдинг"; rule.sCS = "Полоса"; rule.text = "М: C245=C255 ; Профиль: Полоса горячекатаная = PL = — *x*;"; ElmGr gr = new ElmGr(); gr.SupplierName = rule.sSupl; gr.guids = new List <string>() { "guid1", "guid2" }; // test 1: Msg.F("Rules not initialyzed") English string s = sub_PriceGr(mod, gr, "en"); Assert.AreEqual("Rules in Model were not initialyzed", s); // test 2: Msg.F("Rules not initialyzed") Russian s = sub_PriceGr(mod, gr, "ru"); Assert.AreEqual("Не инциированы правила модели", s); // test 3: Rules initialyzed, works with CompSet and Components, Rule, MsgF Wrong LoadDescriptor gr.Prf = "I20"; gr.prf = "i20"; rule.text = "Профиль: Балка =I*"; string comp_txt = "Балка 20"; rule.ruleDP = new DPar.DPar(rule.text); rule.synonyms = rule.RuleSynParse(rule.text); // var syns = rule.synonyms[Section.Section.SType.Profile].ToList(); List <Comp> comps = new List <Comp>() { new Comp(new DP("Prf:I10; Price:23456")), new Comp(new DP("Prf:I20; Price:34567")) }; Supl supl = new Supl("СтальХолдинг", init: false); string LoadDescriptor = "M:1; опис:3; профиль:2; цена: 4; Ед: руб/т"; CS cs = new CS("Балка", supl, LoadDescriptor, comps); Comp comp = new Comp(); comp.compDP = new DP("Prf: " + comp_txt); mod.Rules.Add(rule); rule.CompSet = cs; s = sub_PriceGr(mod, gr, "en", _prefix: "Msg.W: "); Assert.AreEqual("CompSet_wrong_LoadDescriptor", s); FileOp.AppQuit(); }
private void OnSupplier_changed(object sender, SelectionChangedEventArgs e) { string curSN = MainWindow.SuplName; Supl selectedSupl = (Supl)Suppliers.SelectedItem; string selSN = selectedSupl.Name; if (!Msg.AskYN("Вы действительно хотите заменить \"{0}\" на \"{1}\"?", curSN, selSN)) { return; } MainWindow.SuplName = selSN; MainWindow.RePricing(); Close(); }
private void OnSupplier_changed(object sender, SelectionChangedEventArgs e) { string oldSupplier = MainWindow.SuplName; Spl selectedSupl = (Spl)Suppliers.SelectedItem; selectedSupplier = selectedSupl.SuplName; log.Info("new Supplier selected = \"" + selectedSupl.SuplName + "\""); var selSupl = suppliers.Find(x => x.Name == selectedSupl.SuplName); if (selSupl == null) { Msg.F("Inconsystent W_Supplier"); } var grOLD = MainWindow.currentGroup; var grNEW = selSupl.getNEWcs(selSupl, grOLD); if (grNEW == null) { Msg.AskOK("\"{0}\" не поставляет [{1}, {2}], но Вы можете изменить Правила" + " и согласовать изменения с проектировщиком." , selSupl.Name, grOLD.Mat, grOLD.Prf); } else { ////// // пересчитывать вес, объем, стоимость группы; диалог по "тому же" сортаменту ////////22/5 selSupl = selSupl.getTotals(); } #if notReady Supl supl = bool csOK = false; do { if (!Msg.AskYN("Вы действительно хотите заменить \"{0}\" на \"{1}\"?" , oldSupplier, selectedSupplier)) { return; } var cs = csOK = } while (csOK); //21/5 MainWindow.SuplName = selSN; //21/5 MainWindow.RePricing(); Close(); #endif // notReady }
private void Supl_CS_Panel() { ElmGr group = MainWindow.currentGroup; if (group == null) { return; } string suplName = group.SupplierName; Supplier.Content = suplName; string csName = group.CompSetName; CompSet.Content = csName; Supl supl = new Supl(suplName); Supl_CS.Text = supl.getSupplierStr(); List <ElmGr> elmGroups = MainWindow.model.elmGroups; MainWindow.model.HighLightElements(Mod.HighLightMODE.Guids, group.guids); double p = 0; foreach (var gr in elmGroups) { if (gr.SupplierName != suplName) { continue; } p += gr.totalPrice; } string sP = string.Format("{0:N2}", p); TotalSupl_price.Text = "Всего по этому поставщику " + sP + " руб"; GrMat.Content = group.Mat; GrPrf.Content = group.Prf; GrVol.Text = string.Format("{0:N1} м3", group.totalVolume); GrWgt.Text = string.Format("{0:N1} кг", group.totalWeight); GrLng.Text = string.Format("{0:N1} м", group.totalLength); GrPrice.Text = string.Format("{0:N2} руб", group.totalPrice); }
public void UT_CompSet_init() { string LoadDescriptor = "M:1; опис:3; профиль:2; цена: 4; Ед: руб/т"; List <Comp> comps = new List <Comp>() { new Comp(new DP("Prf:I10")), new Comp(new DP("Prf:I20")) }; Supl supl = new Supl("СтальХолдинг", init: false); CompSet cs = new CompSet("Балка", supl, LoadDescriptor, comps); Assert.AreEqual("Балка", cs.name); Assert.AreEqual("1", cs.csDP.dpar[SType.Material]); Assert.AreEqual("2", cs.csDP.dpar[SType.Profile]); Assert.AreEqual("3", cs.csDP.dpar[SType.Description]); Assert.AreEqual("4", cs.csDP.dpar[SType.Price]); Assert.AreEqual("СтальХолдинг", cs.Supplier.Name); Assert.AreEqual(2, cs.Components.Count); Assert.AreEqual("I10", cs.Components[0].Str(SType.Profile)); Assert.AreEqual("I20", cs.Components[1].Str(SType.Profile)); }
public WindowSupplierChoice() { InitializeComponent(); Title = "TSmatch: выбор поставщика"; List <Supl> items = new List <Supl>(); Docs doc = Docs.getDoc(Decl.SUPPLIERS); for (int i = doc.i0; i <= doc.il; i++) { string Name = doc.Body.Strng(i, Decl.SUPL_NAME); string city = doc.Body.Strng(i, Decl.SUPL_CITY); int Indx = doc.Body.Int(i, Decl.SUPL_INDEX); string Strt = doc.Body.Strng(i, Decl.SUPL_STREET); string Url = doc.Body.Strng(i, Decl.SUPL_URL); if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(city)) { continue; } Supl s = new Supl(Name, Indx, city, Strt, Url); items.Add(s); } Suppliers.ItemsSource = items; }
public void UT_CompSet_init_Naive() { boot.Init(); Mod mod = new Mod(); // test 0: бетон -> должен быть DP[UNIT_Vol] Supl spl = new Supl("ГК Монолит СПб"); CompSet csb = new CompSet("Товарный бетон", spl); Assert.IsNotNull(csb); Assert.IsNotNull(csb.csDP); Assert.AreEqual(4, csb.csDP.dpStr.Count); Assert.IsTrue(csb.csDP.dpar.ContainsKey(SType.UNIT_Vol)); // test 1: after bug "Ед: руб/т" не попадал в compDP -> compDP содержит SType.UNIT_Weight Supl supl = new Supl("ЛенСпецСталь"); CompSet cs = new CompSet("Полоса", supl); Assert.IsTrue(cs.csDP.dpar.ContainsKey(SType.UNIT_Weight)); // test 2: Check if all Rules have CompSet with Section Unit_ mod = mod.sr.SetModel(boot, initSupl: true); Assert.IsTrue(mod.Rules.Count > 0); Rule.Rule r = mod.Rules.ToList()[3]; foreach (var rule in mod.Rules) { var csDP = rule.CompSet.csDP; bool bw = csDP.dpStr.ContainsKey(SType.UNIT_Weight); bool bv = csDP.dpStr.ContainsKey(SType.UNIT_Vol); Assert.IsTrue(bw || bv); } FileOp.AppQuit(); }
public void Init() { Supplier = new Supl(sSupl); CompSet = new CmpSet(sCS, Supplier); CompSet.doc.Close(); }