Ejemplo n.º 1
0
 public void Copy(ProductSet ps, string FileName, string SheetN,
     string LoadDescriptor, int i0 = -1, int il = -1)
 {
     name = ps.name;
     ValidUntil = ps.ValidUntil;
     Date = ps.Date;
     SuplName = ps.SuplName;
     PSid = ps.PSid;
     RuleText = ps.RuleText;
     psMD5 = ps.psMD5;
     this.FileName = FileName;
     string filepath = Path.Combine(boot.ExcelDir, FileName);
     if (!boot.fo.IsFileExist(filepath))
         throw new ArgumentException($"Нет файла \"{filepath}\"");
     this.SheetN = SheetN;
     ////////////////if(!boot.Doc.Init(name, boot.ExcelDir, FileName, SheetN))
     ////////////////{ }
     ////////////////var doc = boot.Doc.GetDoc(name);
     // 18/2 ////////bool b = doc.IsDocExist(name);
     ////////////////boot.fo.FileOpen(boot.ExcelDir, FileName);
     ////////////////if(!boot.fo.IsSheetExist(SheetN))
     ////////////////    throw new ArgumentException($"В файле \"{filepath}\" нет листа \"{SheetN}\"");
     this.LoadDescriptor = LoadDescriptor;
     if (string.IsNullOrEmpty(LoadDescriptor))
         throw new ArgumentNullException("пустой LoadDescriptor");
 }
Ejemplo n.º 2
0
 public void Init(Boot boot, ProductSet ps, string id = "")
 {
     this.boot = boot;
     this.ps = ps;
     if (string.IsNullOrEmpty(id))
         id = boot.Lib.IdGen(Declaration.IdTypeProd);
     this.id = id;
 }
Ejemplo n.º 3
0
 public void WrXMLfrExcel(string pathExcel, string fileExcel, string SheetExcel,
     string LoadDescriptor, string pathXML, string fileXML = "")
 {
     const string EXC = "ExcelDoc";
     if (string.IsNullOrEmpty(fileXML)) fileXML = Path.ChangeExtension(fileXML, "xml");
     if (!boot.Doc.Init(EXC, pathExcel, fileExcel, SheetExcel, FirstRow: 8))
         throw new Exception("No Excel price-list");
     var ps = new ProductSet();
     //25/12           ps.Init();
     var doc = boot.Doc.GetDoc(EXC);
     for (int i = doc.i0; i <= doc.il; i++)
     {
         var p = new Product();
         p.name = doc.Str(i, 1);
         p.price = doc.Dec(i, 4);
         ps.Products.Add(p);
     }
 }
Ejemplo n.º 4
0
 public void Update(string SuplName, string psName = "")
 {
     var AllSupl = boot.Suppliers.AllSuppliers;
     Supplier supl = AllSupl.Find(x => x.name == SuplName);
     if (supl == null) throw new Exception($"No Supplier=\"{SuplName}\" to update");
     if (psName == "")
     {
         foreach (var prSet in supl.productSets)
             Update(supl.name, prSet.name);
         return;
     }
     ProductSet ps = supl.productSets.Find(x => x.name == psName);
     if (ps == null)
         throw new Exception($"No ProductSet=\"{psName}\" is Supplier=\"{SuplName}\"");
     ps.Init(boot);
     ps.SuplName = SuplName;
     ps.Update();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Update - read updated pricelist from Excel and put it to AllSuppliers
 /// </summary> 
 public void Update(psInit psi)
 {
     SupplierInit supl_I = boot.ssInit.Find(x => x.name == SuplName);
     int indx = supl_I.pssInit.FindIndex(x => x.name == name);
     if (indx > 0 && indx < supl_I.pssInit.Count)
         supl_I.pssInit[indx] = psi;
     else supl_I.pssInit.Add(psi);
     var doc = boot.Doc;
     string docName = SuplName + " " + name;
     doc.Init(docName, boot.ExcelDir, psi.FileName, psi.SheetN,
         LoadDescription: psi.LoadDescriptor, FirstRow: psi.i0,
         RuleText: RuleText.ToArray());
     doc = doc.GetDoc(docName);
     Init(name, doc);
     var ss = boot.Suppliers.AllSuppliers;
     Supplier supl = ss.Find(x => x.name == SuplName);
     ProductSet ps = supl.productSets.Find(x => x.name == name);
     if (ps == null) ps = this;
     else supl.productSets.Add(this);
 }
Ejemplo n.º 6
0
        public void Update(string suplName, string psName)
        {
            SupplierInit supl_I = boot.ssInit.Find(x => x.name == suplName) ??
                throw new ArgumentException($"SupplierInit {suplName} not found");
            psInit psi = supl_I.pssInit.Find(x => x.name == psName) ??
                throw new ArgumentException($"psInit {psName} not found for SupplierInit=\"{suplName}\"");
            string LoadDescription = psi.LoadDescriptor;
            Supplier supl = boot.Suppliers.AllSuppliers.Find(x => x.name == suplName) ??
                throw new ArgumentException($"Supplier {suplName} not found");
            ProductSet ps = supl.productSets.Find(x => x.name == suplName) ??
                throw new ArgumentException($"ProductSet=\"{psName}\" not found for Supplier=\"{suplName}\"");
            int indx = supl.productSets.IndexOf(ps);
            string docName = suplName + "_" + psName;
//17/2           boot.Doc.Init(docName, boot.ExcelDir, );
                

            int suplIndex = boot.Suppliers.AllSuppliers.IndexOf(supl);
 //17/2           boot.Suppliers.AllSuppliers[suplIndex].productSets[indx] = newPS;


            throw new NotImplementedException();

        }
Ejemplo n.º 7
0
 public Product(string _name, double _price, List<object> Fields, ProductSet ps) : this(_name, _price)
 {
     this.Fields = Fields;
     if (ps == null) throw new ArgumentNullException();
 }