public static void setProduct(int waybill_no, int barcode, int supplier_no, int product_no, float unit_input_price, int amount, float price, DateTime debt_date, string product_name) { if (getProductbyBarcode(barcode) == null) { //eklenecek ürünün database de olup olmadığınıa bakılır. Supplier sup = Supplier.setSupplier(supplier_no); using (MngContext context = new MngContext()) { Product p = new Product { waybill_no = waybill_no, barcode = barcode, supplier_no = supplier_no, product_no = product_no, unit_input_price = unit_input_price, amount = amount, price = price, product_name = product_name, Supplier = sup, MarketDebt = MarketDebt.setMDebt(price, debt_date, barcode), }; context.Products.Add(p); context.SaveChanges(); } } }
public static MarketDebt setMDebt(float debt_amount, DateTime debt_date, int barcode) { using (MngContext context = new MngContext()) { MarketDebt m = new MarketDebt { debt_amount = debt_amount, debt_date = debt_date, barcode = barcode, payed = false, //ürün stoğa eklendiğinde borç oluşur daima }; context.MarketDebts.Add(m); context.SaveChanges(); return(m); } }