protected override TResult Execute(CodeActivityContext context) { Document responce = new Document(); List <string> docData = context.GetValue(this.Data).ToList(); List <Product> products = context.GetValue(this.Products).ToList(); if (context.GetValue(this.DocType) == "Bill") { Bill bill = new Bill(docData[0], docData[1], docData[2], docData[3], docData[4]); bill.SetProductList(products); bill.CalcGoodsSum(); responce = bill; } else if (context.GetValue(this.DocType) == "Invoice") { Invoice invoice = new Invoice(docData[0], docData[1], docData[2], docData[3], docData[4], docData[5]); invoice.SetProductList(products); invoice.CalcGoodsSum(); responce = invoice; } else if (context.GetValue(this.DocType) == "Reciept") { Reciept reciept = new Reciept(docData[0], docData[1], docData[2], docData[3], docData[4]); reciept.SetProductList(products); reciept.CalcGoodsSum(); responce = reciept; } NewDoc.Set(context, responce); return(responce as TResult); }
private void RecieptConstructorWindow_Shown(object sender, EventArgs e) { pList = new BindingList <Product>(reciept.Products); dataGridViewProducts.DataSource = pList; reciept.SetProductList(pList.ToList()); TextBoxBinding(); textBoxPaymentName.DataBindings.Add("Text", reciept, "PaymentName"); }
public bool SetDocumentReciept(string[] data, Product[] productsPacket) { if (data.Length != 5) { return(false); } foreach (var s in data) { if (string.IsNullOrWhiteSpace(s)) { return(false); } } Reciept reciept = new Reciept(data[0], data[1], data[2], data[3], data[4]); reciept.SetProductList(productsPacket.ToList()); reciept.CalcGoodsSum(); using (document_dbEntities db = new document_dbEntities()) { Reciepts reciept_To_Db = new Reciepts { DocId = reciept.DocId, DocDate = reciept.DocDate, Provider = reciept.Provider, Client = reciept.Client, PaymentName = reciept.PaymentName, GoodSum = (decimal)reciept.GoodsSum, }; db.Reciepts.Add(reciept_To_Db); db.SaveChanges(); List <Products> products_To_Db = new List <Products>(); foreach (Product p in productsPacket) { products_To_Db.Add(new Products { Name = p.Name, MeasureUnit = p.MeasureUnit, Count = p.Count, Price = (decimal)p.Price, Sum = (decimal)p.Sum, Reciepts = reciept_To_Db }); } db.Products.AddRange(products_To_Db); db.SaveChanges(); } return(true); }