public static bool AddBill(Mc_Bill bill) { List <Mc_Products> ProductsList = bill.loadProductsList; bill.tractionID = AutoIDGenarator("mc_transaction"); foreach (Mc_Products pro in ProductsList) { if (pro.productID != null && bill.tractionID != null) { if (AddTransaction(bill)) { Mc_Product_Tranasaction billproducts = new Mc_Product_Tranasaction(); billproducts.trID = bill.tractionID; billproducts.pID = pro.productID; billproducts.Qty = pro.productQty; billproducts.Unitprice = pro.productUnitPrice; billproducts.Amountprice = pro.productUnitPrice; if (AddProduct_Transaction(billproducts) == false) { return(false); } } } else { return(false); } } return(false); }
public static bool AddTransaction(Mc_Bill tr) { MySqlConnection Conn = DBConnection.ConnMcComputers; string Strsql = "INSERT INTO `mc_transaction`(`mc_trID`,`mc_trTotalPrice`) VALUES('" + tr.tractionID + "','" + tr.Totalamount + "')"; try { if (Conn.State == ConnectionState.Closed) { Conn.Open(); } MySqlCommand cmd = new MySqlCommand(Strsql, Conn); cmd.CommandTimeout = 60; if (cmd.ExecuteNonQuery() == 1) { return(true); } } catch (MySqlException er) { Console.WriteLine(er.Message.ToString()); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } return(false); }