public static int UpdateOrders(Order iOrdOld, Order iOrdNew) { RemoveOrders(iOrdOld.Id); AddOrder(iOrdNew); return 0; }
public static void OrdInsert(Order iOrd) { if (GlobalVars.ConnectedToDatabase) { MySqlConnection con = new MySqlConnection(MyConnectionString); con.Open(); try { MySqlCommand cmd = con.CreateCommand(); cmd.CommandText = "insert into orders(id, purchaser_id, items_desc, amount) values("+iOrd.Id + "," + iOrd.Purchaser.Id + ",'" + iOrd.ItemsDescription+"',"+iOrd.Amount + ");"; cmd.ExecuteNonQuery(); } catch (Exception) { } finally { if (con.State == ConnectionState.Open) { con.Close(); } } } }
public static int AddOrder(Order iOrder) { if((GlobalVars.LoggedInUser.AccessLvl == AccessLevel.User) || (GlobalVars.LoggedInUser.AccessLvl == AccessLevel.Doctor) || (GlobalVars.LoggedInUser.AccessLvl == AccessLevel.Admin)) { GlobalVars.OrdersList.Add(new Order(++GlobalVars.OrdersIdCounter, iOrder.Purchaser, iOrder.ItemsDescription, iOrder.Amount)); Serialize(GlobalVars.OrdersList, GlobalVars.OrdersDbName); CreatingDatabaseSelects.OrdInsert(iOrder); return 0; } return 1; }
/* -- Orders -- */ public static void OrdUpdate(Order iOrd) { if (GlobalVars.ConnectedToDatabase) { OrdDelete(iOrd.Id); OrdInsert(iOrd); } }