コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: IngredientDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        public List <tb_ingredient> GetListOfIngreient()
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_ingredient
                              select c).ToList();

                    // Assign to DataGridView
                    if (ds.Count() > 0)
                    {
                        log.Info("Get List Of Ingredient Success");
                        return(ds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("SmoothDataLayer => GetListOfIngredient(): " + ex.Message);
                return(null);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
ファイル: IngredientDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        public List <tb_ingredient> GetListOfIngredientFilter(string Name)
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_ingredient
                              where c.name == Name
                              select c).ToList();

                    if (ds.Count() > 0)
                    {
                        log.Info("Get List Of Employee Success");
                        return(ds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("SmoothDataLayer => GetLisOfPopupFilter(): " + ex.Message);
                return(null);
            }
        }
コード例 #6
0
        public List <tb_popup> GetListOfPopupFilter(string name)
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_popup
                              where c.name.Contains(name)
                              where c.is_active == 1
                              orderby c.popup_id ascending
                              select c).ToList();

                    // Assign to DataGridView
                    if (ds.Count() > 0)
                    {
                        log.Info("SmoothDataLayer -- GetLisOfPopupFilter Success");
                        return(ds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("SmoothDataLayer => GetLisOfPopupFilter(): " + ex.Message);
                return(null);
            }
        }
コード例 #7
0
        public List <tb_product> GetListOfProductFilter(string Name)
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_product
                              where c.name == Name
                              select c).ToList();

                    // Assign to DataGridView
                    if (ds.Count() > 0)
                    {
                        log.Info("Get List Of Product Success");
                        return(ds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("SmoothDataLayer => GetLisOfProductFilter(): " + ex.Message);
                return(null);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        public List <tb_printer_log> GetListOfPrinterLog()
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_printer_log
                              select c).Take(50).ToList();

                    // Assign to DataGridView
                    if (ds.Count() > 0)
                    {
                        log.Info("SmoothDataLayer -- GetListOfPrinterLog Success");
                        return(ds);
                    }
                    else
                    {
                        log.Error("SmoothDataLayer => GetListOfPrinter():");
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("SmoothDataLayer => GetListOfPrinterLog(): " + ex.Message);
                return(null);
            }
        }
コード例 #10
0
ファイル: EmployeeDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        public int CheckStaffStatus(int employeeID)
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_employee
                              where c.employee_id == employeeID
                              select c).FirstOrDefault();

                    log.Info("Get List Of Employee Success");
                    if (ds.status_id == null)
                    {
                        return(default(int));
                    }
                    else
                    {
                        return(-1);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("DataLayer => GetEmployeeDetailByPassword(): " + ex.Message);
                return(-1);
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
ファイル: IngredientDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        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);
            }
        }
コード例 #13
0
        //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);
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
ファイル: EmployeeDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        /// <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);
            }
        }
コード例 #17
0
ファイル: EmployeeDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        /// <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);
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        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);
            }
        }
コード例 #20
0
        public List <tb_order> GetListOfOrder(int Top)
        {
            try
            {
                using (var db = new smoothdbEntities())
                {
                    var ds = (from c in db.tb_order
                              where c.is_active == 1
                              orderby c.order_id descending
                              select c).Take(Top).ToList();

                    // Assign to DataGridView
                    if (ds.Count() > 0)
                    {
                        log.Info("SmoothDataLayer -- GetListSection Success");
                        return(ds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("SmoothDataLayer => GetListOfOrder(): " + ex.Message);
                return(null);
            }
        }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
        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);
            }
        }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
        /// <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);
            }
        }
コード例 #27
0
ファイル: EmployeeDAO.cs プロジェクト: MrGOStepz/SmoothPOS
        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);
            }
        }
コード例 #28
0
        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);
            }
        }
コード例 #29
0
        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);
            }
        }
コード例 #30
0
        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);
            }
        }