public bool Update_discount(product p) { int check = -1; using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } using (var transaction = db.BeginTransaction()) { check = db.Execute("Update_product_discount", new { id = p.id, discount_id = p.discount_id }, commandType: CommandType.StoredProcedure, transaction: transaction); transaction.Commit(); } } if (check >= 1) { return(true); } else { return(false); } }
private void FMLogin_KeyDown(object sender, KeyEventArgs e) { if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.M) { Utils.FM.SetupConnection configConnFM = new SetupConnection(true); configConnFM.ShowDialog(); } }
public bool CreateBill(List <CartDetail> lst) { int check = -1; using (var db = SetupConnection.ConnectionFactory()) { try { if (db.State == ConnectionState.Closed) { db.Open(); } using (var transaction = db.BeginTransaction()) { check = db.Execute("CreateBill", new { date_create = this.date_create, users_id = this.users_id, total_money = this.total_money, method = this.method, Status = this.Status, FullName = this.FullName, Email = this.Email, Address = this.Address, Phone = this.Phone, Gender = this.Gender }, commandType: CommandType.StoredProcedure, transaction: transaction); transaction.Commit(); // Create Detai Bill int currentBill = db.QuerySingleOrDefault <int>("SELECT IDENT_CURRENT ('orders')"); if (!CreateBillDetail(lst, currentBill)) { return(false); } } } catch (Exception ex) { Trace.WriteLine(ex.Message); return(false); } } if (check >= 1) { return(true); } else { return(false); } }
public static string getUser(int?id) { using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } return(db.Query <user>("SELECT fullname FROM dbo.users WHERE id ='{0}'", id).ToString()); } }
public static List <orderFnc> Get() { using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } return(db.Query <orderFnc>("SELECT * FROM dbo.orders").ToList()); } }
public static bool Post(product p) { int check = -1; using (var db = SetupConnection.ConnectionFactory()) { try { if (db.State == ConnectionState.Closed) { db.Open(); } using (var transaction = db.BeginTransaction()) { check = db.Execute("Ins_product", new { id = p.id, sku = p.sku, name = p.name, price = p.price, Ghz = p.Ghz, color = p.color, sensor = p.sensor, cpu = p.cpu, ram = p.ram, storage = p.storage, camera_front = p.camera_front, camera_rear = p.camera_rear, battery = p.battery, display = p.display, sim = p.sim, status = p.status }, commandType: CommandType.StoredProcedure, transaction: transaction); transaction.Commit(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); return(false); } } if (check >= 1) { return(true); } else { return(false); } }
public bool Delete() { using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } return(db.QuerySingleOrDefault <bool>("SELECT * FROM dbo.products")); } }
// GET: Customer public static List <order> getorder(int?id) { using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } var sql = "SELECT * FROM dbo.orders Where users_id =@id;"; return(db.Query <order>(sql, new { id = id }).ToList()); } }
public bool CreateBillDetail(List <CartDetail> lst, int currentBill) { int check = -1; try { using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } foreach (CartDetail sp in lst) { using (var transaction = db.BeginTransaction()) { check = db.Execute("ins_BillDetail", new { order_id = currentBill, quantity = sp.Quantity, money = sp.Price, product_id = sp.ID, }, commandType: CommandType.StoredProcedure, transaction: transaction); transaction.Commit(); } } } if (check >= 1) { return(true); } return(false); } catch (Exception ex) { Trace.WriteLine(ex.Message); return(false); } }
public static orderFnc Get(int id) { orderFnc b = new orderFnc(); b = Get().Find(x => x.id == id); string query = string.Format("SELECT * FROM dbo.order_detail WHERE order_id ='{0}'", id); using (var db = SetupConnection.ConnectionFactory()) { if (db.State == ConnectionState.Closed) { db.Open(); } b.orderDetail = db.Query <order_detail>(query).ToList(); foreach (var item in b.orderDetail) { //item.ProductName = Product.Get(item.ProductID).Name; item.product.name = productFnc.Get(item.product_id).name; } } return(b); }
public static bool Del(int id) { int check = -1; using (var db = SetupConnection.ConnectionFactory()) { try { if (db.State == ConnectionState.Closed) { db.Open(); } using (var transaction = db.BeginTransaction()) { check = db.Execute("DelBill", new { order_id = id }, commandType: CommandType.StoredProcedure, transaction: transaction); transaction.Commit(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); return(false); } } if (check >= 1) { return(true); } else { return(false); } }