public int AddIngredient(string Name, string ImagePath) { try { try { using (var db = new smoothdbEntities()) { var ds = db.tb_ingredient.Add(new tb_ingredient() { name = Name, image_path = ImagePath }); db.SaveChanges(); } return(1); } catch (Exception ex) { log.Error("DataLayer => AppNewEmployee(): " + ex.Message); return(-1); } } catch (Exception ex) { log.Error("SmoothDataLayer => AddIngredient(): " + ex.Message); return(-1); } }
public int AddProduct(string Name, string Sname, string Description, int PopupID, float PriceInc, int Stock, int Avaliable, int PdInID, int TypeOfFood, string ImagePath) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_product.Add(new tb_product() { short_name = Sname, description = Description, avaliable = Avaliable, product_ingredient_id = PdInID, popup_id = PopupID, stock = Stock, price = PriceInc, image_path = ImagePath, type_food_id = TypeOfFood }); db.SaveChanges(); return(1); } } catch (Exception ex) { log.Error("DataLayer => AddProduct(): " + ex.Message); return(-1); } }
public int UpdateTable(int TableID, float MarginTop, float MarginBot, float MarginLeft, float MarginRight) { try { using (var db = new smoothdbEntities()) { var update = db.tb_table_section.Where(o => (o.table_section_id == TableID)).FirstOrDefault(); if (update != null) { update.margin_top = MarginTop; update.margin_bottom = MarginBot; update.margin_left = MarginLeft; update.margin_right = MarginRight; } db.SaveChanges(); } log.Info("SmoothDataLayer -- UpdateTable Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateTable(): " + ex.Message); return(-1); } }
public int UpdateOrder(int OrderID, string OrderDT, int OrderType, int EmployeeID, int TableID, int OrderStatusID, int Payment_ID, int CustomerID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_order.Where(o => (o.order_id == OrderID)).FirstOrDefault(); if (update != null) { update.order_at = DateTime.Parse(OrderDT); update.order_type_id = OrderType; update.employee_id = EmployeeID; update.table = TableID; update.order_status_id = OrderStatusID; update.payment_id = Payment_ID; update.customer_id = CustomerID; } db.SaveChanges(); } log.Info("SmoothDataLayer -- UpdateOrder Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateOrder(): " + ex.Message); return(-1); } }
public int AddPrinterLog(int PrinterID, string DT, string stringJson) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_printer_log.Add(new tb_printer_log() { printer_id = PrinterID, print_dt = DateTime.Parse(DT), printer_detail = stringJson }); db.SaveChanges(); } log.Info("SmoothDataLayer -- AddPrinterLog Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => AddPrinterLog(): " + ex.Message); return(-1); } }
public int UpdateOrderDetail(int OrderDetailID, int ProductID, int PopupItemID, int OrderID, int ProductQty, float Amount, string Comment, int CookStatus) { try { using (var db = new smoothdbEntities()) { var update = db.tb_order_detail.Where(o => (o.order_detail_id == OrderDetailID)).FirstOrDefault(); if (update != null) { update.cook_status = CookStatus; update.product_id = ProductID; update.popup_item_id = PopupItemID; update.order_id = OrderID; update.product_qty = ProductQty; update.amount = Amount; update.comment = Comment; } db.SaveChanges(); } return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateSectionStable(): " + ex.Message); return(-1); } }
public int AddPrinter(string Name, string PrinterIP, string PritnerPort) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_printer.Add(new tb_printer() { name = Name, printer_ip = PrinterIP, printer_port = PritnerPort }); db.SaveChanges(); } log.Info("SmoothDataLayer -- AddPrinter Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => AddPrinter(): " + ex.Message); return(-1); } }
public int AddTable(string UName, string Name, int SectionID, float MarginTop, float MarginBot, float MarginLeft, float MarginRight) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_table_section.Add(new tb_table_section() { name = Name, section_id = SectionID, margin_top = MarginTop, margin_bottom = MarginBot, margin_left = MarginLeft, margin_right = MarginRight, height = 75, width = 75, is_active = 1 }); db.SaveChanges(); log.Info("SmoothDataLayer -- AddTable Success"); return(ds.table_section_id); } } catch (Exception ex) { log.Error("SmoothDataLayer => AddTable(): " + ex.Message); return(-1); } }
public int DeleteOrder(int OrderID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_order.Where(o => (o.order_id == OrderID)).FirstOrDefault(); if (update != null) { //TODO Add is_active in Order Table update.is_active = 0; } db.SaveChanges(); } log.Info("SmoothDataLayer -- DeleteOrder Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => DeleteOrder(): " + ex.Message); return(-1); } }
//TODO Review public int UpdateLocationMenu(int LocationMenuID, int ProductID, int LocationTabID, int Column, int Row) { try { using (var db = new smoothdbEntities()) { var update = db.tb_location_menu.Where(o => (o.location_menu_id == LocationMenuID)).FirstOrDefault(); if (update != null) { update.product_id = ProductID; update.location_tab_id = LocationTabID; update.column_no = Column; update.row_no = Row; } db.SaveChanges(); } log.Info("SmoothDataLayer -- UpdateLocationMenu Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateLocationMenu(): " + ex.Message); return(-1); } }
public int AddOrder(string OrderDT, int OrderType, int EmployeeID, int TableID, int OrderStatusID, int Payment_ID, int CustomerID) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_order.Add(new tb_order() { order_at = DateTime.Parse(OrderDT), order_type_id = OrderType, employee_id = EmployeeID, table = TableID, order_status_id = OrderStatusID, payment_id = Payment_ID, customer_id = CustomerID }); db.SaveChanges(); log.Info("SmoothDataLayer -- AddOrder Success"); return(ds.order_id); } } catch (Exception ex) { log.Error("SmoothDataLayer => AddOrder(): " + ex.Message); return(-1); } }
public int AddLocationMenu(int ProductID, int LocationTabID, int Column, int Row) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_location_menu.Add(new tb_location_menu() { product_id = ProductID, location_tab_id = LocationTabID, column_no = Column, row_no = Row }); db.SaveChanges(); return(ds.product_id ?? -1); } } catch (Exception ex) { log.Error("SmoothDataLayer => AddLocationMenu: " + ex.Message); return(-1); } }
/// <summary> /// Update Profile Employee by Employee ID /// </summary> /// <param name="EmployeeID"></param> /// <param name="FirstName"></param> /// <param name="LastName"></param> /// <param name="Phone"></param> /// <param name="Email"></param> /// <returns></returns> public int UpdateProfileEmployee(int EmployeeID, string FirstName, string LastName, string NickName, string Phone, string Email, string Password) { try { using (var db = new smoothdbEntities()) { var update = db.tb_employee.Where(o => (o.employee_id == EmployeeID)).FirstOrDefault(); if (update != null) { update.first_name = FirstName; update.last_name = LastName; update.nick_name = NickName; update.phone = Phone; update.email = Email; update.password = Password; } db.SaveChanges(); } log.Info("Update Profile Employee Success"); return(1); } catch (Exception ex) { log.Error("DataLayer => UpdateProfileEmployee(): " + ex.Message); return(-1); } }
/// <summary> /// Add New Employee /// </summary> /// <param name="FirstName"></param> /// <param name="LastName"></param> /// <param name="Phone"></param> /// <param name="Email"></param> /// <param name="Password"></param> /// <returns></returns> public int AddNewEmployee(string FirstName, string LastName, string NickName, string Phone, string Email, string Password) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_employee.Add(new tb_employee() { first_name = FirstName, last_name = LastName, nick_name = NickName, phone = Phone, email = Email, password = Password }); db.SaveChanges(); } return(1); } catch (Exception ex) { log.Error("DataLayer => AppNewEmployee(): " + ex.Message); return(-1); } }
public int AddOrderDetail(int ProductID, int PopupItemID, int OrderID, int ProductQty, float Amount, string Comment, int CookStatus) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_order_detail.Add(new tb_order_detail() { product_id = ProductID, popup_item_id = PopupItemID, order_id = OrderID, product_qty = ProductQty, amount = Amount, comment = Comment, cook_status = CookStatus }); db.SaveChanges(); log.Info("SmoothDataLayer -- AddOrderDetail Success"); return(ds.order_detail_id); } } catch (Exception ex) { log.Error("SmoothDataLayer => AddOrder(): " + ex.Message); return(-1); } }
public int UpdateProduct(int ProductID, string Name, string Sname, string Description, int PopupID, float PriceInc, int Stock, int Avaliable, int PdInID, int typeOfFood, string ImagePath) { try { using (var db = new smoothdbEntities()) { var update = db.tb_product.Where(o => (o.product_id == ProductID)).FirstOrDefault(); if (update != null) { update.name = Name; update.short_name = Sname; update.description = Description; update.avaliable = Avaliable; update.product_ingredient_id = PdInID; update.popup_id = PopupID; update.stock = Stock; update.price = PriceInc; update.image_path = ImagePath; update.type_food_id = typeOfFood; } db.SaveChanges(); } log.Info("Update UpdateProduct Success"); return(1); } catch (Exception ex) { log.Error("DataLayer => UpdateProduct(): " + ex.Message); return(-1); } }
public int UpdatePopup(int PopupID, string Name, List <int> lstSupPopupID, List <string> lstName, List <float> lstPrice, List <string> lstImagePath) { try { if (lstName.Count != lstPrice.Count && lstPrice.Count != lstImagePath.Count && lstName.Count != lstImagePath.Count) { return(-1); } using (var db = new smoothdbEntities()) { var update = db.tb_popup.Where(o => (o.popup_id == PopupID)).FirstOrDefault(); if (update != null) { update.name = Name; } db.SaveChanges(); for (int i = 0; i < lstSupPopupID.Count; i++) { var updateItem = db.tb_popup_item.Where(o => (o.popup_id == PopupID)).FirstOrDefault(); if (updateItem != null) { updateItem.name = lstName[i]; updateItem.popup_id = PopupID; updateItem.price = lstPrice[i]; updateItem.image_path = lstImagePath[i]; } } } log.Info("SmoothDataLayer -- Update Popup Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdatePopup(): " + ex.Message); return(-1); } }
public int DeleteOrderDetail(int OrderDetailID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_order_detail.Where(o => (o.order_detail_id == OrderDetailID)).FirstOrDefault(); if (update != null) { update.is_active = 0; } db.SaveChanges(); return(1); } } catch (Exception ex) { log.Error("SmoothDataLayer => DeleteOrderDetail(): " + ex.Message); return(-1); } }
/// <summary> /// Add Popup Table and List PopupTable /// </summary> /// <param name="Name"></param> /// <param name="lstName">List of name SubPopup</param> /// <param name="lstPrice">List of price Subpopup</param> /// <param name="lstImagePath">List of Path image</param> /// <returns></returns> public int AddPopup(string Name, List <string> lstName, List <float> lstPrice, List <string> lstImagePath) { try { //Check They are equal if (lstName.Count != lstPrice.Count && lstPrice.Count != lstImagePath.Count && lstName.Count != lstImagePath.Count) { return(-1); } using (var db = new smoothdbEntities()) { var ds = db.tb_popup.Add(new tb_popup() { name = Name }); int tempId = ds.popup_id; for (int i = 0; i < lstName.Count; i++) { var dspop = db.tb_popup_item.Add(new tb_popup_item() { popup_id = tempId, name = lstName[i], price = lstPrice[i], image_path = lstImagePath[i] }); } db.SaveChanges(); log.Info("SmoothDataLayer -- Add Popup Success"); return(ds.popup_id); } } catch (Exception ex) { log.Error("SmoothDataLayer => AddPopup(): " + ex.Message); return(-1); } }
public int AddSectionTable(string Name) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_section.Add(new tb_section() { name = Name }); db.SaveChanges(); } log.Info("SmoothDataLayer -- AddSectionTable Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => AddTable(): " + ex.Message); return(-1); } }
public int RemoveLocationTab(int LocationTabID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_location_tab.Where(o => (o.location_tab_id == LocationTabID)).FirstOrDefault(); if (update != null) { update.is_active = 0; } db.SaveChanges(); } log.Info("Update Profile Employee Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => RemoveLocationTab: " + ex.Message); return(-1); } }
public int UpdateEmployeeStatus(int employeeID, int statusID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_employee.Where(o => (o.employee_id == employeeID)).FirstOrDefault(); if (update != null) { update.status_id = statusID; } log.Info("UpdateEmployeeStatus Success"); db.SaveChanges(); return(1); } } catch (Exception ex) { log.Error("DataLayer => UpdateStaffStatus(): " + ex.Message); return(-1); } }
public int DeleteProduct(int ProductID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_product.Where(o => (o.product_id == ProductID)).FirstOrDefault(); if (update != null) { update.is_active = 0; } db.SaveChanges(); } log.Info("SmoothDataLayer -- Delete Product Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => DeleteProduct(): " + ex.Message); return(-1); } }
public int UpdateSectiontable(int SectionID, string Name) { try { using (var db = new smoothdbEntities()) { var update = db.tb_table_section.Where(o => (o.section_id == SectionID)).FirstOrDefault(); if (update != null) { update.name = Name; } db.SaveChanges(); } log.Info("SmoothDataLayer -- UpdateSectionStable Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateSectionStable(): " + ex.Message); return(-1); } }
public int UpdatePrinter(int PrinterID, string Name) { try { using (var db = new smoothdbEntities()) { var update = db.tb_printer.Where(o => (o.printer_id == PrinterID)).FirstOrDefault(); if (update != null) { update.name = Name; } db.SaveChanges(); } log.Info("SmoothDataLayer -- UpdatePrinter Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdatePrinter(): " + ex.Message); return(-1); } }
public int UpdateOrderDetailCookStatus(int OrderID, int ProductID, int CookStatus) { try { using (var db = new smoothdbEntities()) { var update = db.tb_order_detail.Where(o => (o.order_id == OrderID)).Where(o => (o.product_id == ProductID)).FirstOrDefault(); if (update != null) { update.cook_status = CookStatus; } db.SaveChanges(); } log.Info("SmoothDataLayer -- UpdateOrder Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateSectionStable(): " + ex.Message); return(-1); } }
public int UpdateIngredient(int IngredientID, string Name, string ImagePath) { try { using (var db = new smoothdbEntities()) { var update = db.tb_ingredient.Where(o => (o.ingredient_id == IngredientID)).FirstOrDefault(); if (update != null) { update.name = Name; update.image_path = ImagePath; } db.SaveChanges(); } log.Info("Update UpdateIngredient Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => UpdateIngredient(): " + ex.Message); return(-1); } }
public int AddPrinterProduct(int PrinterID, int ProdudctID) { try { using (var db = new smoothdbEntities()) { var ds = db.tb_printer_product.Add(new tb_printer_product() { product_id = ProdudctID, printer_id = PrinterID }); db.SaveChanges(); } log.Info("SmoothDataLayer -- AddPrinterProduct Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => AddPrinterProduct(): " + ex.Message); return(-1); } }
public int DeleteIngredient(int IngredientID) { try { using (var db = new smoothdbEntities()) { var del = db.tb_ingredient.Where(o => (o.ingredient_id == IngredientID)).FirstOrDefault(); if (del != null) { db.tb_ingredient.Remove(del); } db.SaveChanges(); } log.Info("Delete Ingredient Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => DeleteIngredient(): " + ex.Message); return(-1); } }
public int RemoveSectionTable(int SectionID) { try { using (var db = new smoothdbEntities()) { var update = db.tb_section.Where(o => (o.section_id == SectionID)).FirstOrDefault(); if (update != null) { update.is_active = 0; } db.SaveChanges(); } log.Info("SmoothDataLayer -- RemoveSectionTable Success"); return(1); } catch (Exception ex) { log.Error("SmoothDataLayer => RemoveSectionTable(): " + ex.Message); return(-1); } }