Пример #1
0
        public double GetPrice()
        {
            double                  Price          = 0;
            double                  convertQantity = 0;
            string                  query          = "SELECT * from SelectedItem";
            List <Inventory>        inventoryList  = new List <Inventory>();
            DataBaseConnectionClass dcc            = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                Inventory inventory = new Inventory();

                inventory.ItemQuantity = Convert.ToInt32(sdr["ItemQuantity"]);
                convertQantity         = (double)inventory.ItemQuantity;
                inventory.ItemPrice    = Convert.ToDouble(sdr["ItemPrice"]);
                Price = (inventory.ItemPrice * convertQantity) + Price;

                inventoryList.Add(inventory);
            }
            dcc.CloseConnection();
            return(Price);
        }
Пример #2
0
        public List <Inventory> GetInventory(string ItemId)
        {
            string query = "SELECT * From Inventroy WHERE (ItemId LIKE '%" + ItemId + "%' OR ItemId LIKE '" + ItemId + "%_%') OR (ItemName LIKE '%" + ItemId + "%' ) ";



            Inventory        inventory     = null;
            List <Inventory> inventoryList = new List <Inventory>();

            DataBaseConnectionClass dcc = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                inventory              = new Inventory();
                inventory.ItemId       = sdr["ItemId"].ToString();
                inventory.ItemName     = sdr["ItemName"].ToString();
                inventory.ItemQuantity = Convert.ToInt32(sdr["ItemQuantity"]);
                inventory.ItemPrice    = Convert.ToDouble(sdr["ItemPrice"]);
                inventoryList.Add(inventory);
            }

            dcc.CloseConnection();
            return(inventoryList);
        }
Пример #3
0
        public List <User> GetUser(string userS)
        {
            string      query    = "SELECT * From UserInfo WHERE (userId LIKE '%" + userS + "%' OR userId LIKE '" + userS + "%_%') OR (userName LIKE '%" + userS + "%' ) OR (userType LIKE '%" + userS + "%' )  ";
            User        user     = null;
            List <User> userList = new List <User>();

            DataBaseConnectionClass dcc = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                user             = new User();
                user.UserId      = sdr["UserId"].ToString();
                user.DateOfBirth = Convert.ToDateTime(sdr["DateOfBirth"]);
                user.UserName    = sdr["UserName"].ToString();
                user.Password    = sdr["Password"].ToString();
                user.Designation = sdr["Designation"].ToString();
                user.Salary      = Convert.ToDouble(sdr["Salary"]);
                user.UserType    = sdr["UserType"].ToString();
                user.DateOfJoing = Convert.ToDateTime(sdr["DateOfJoing"]);
                user.ContactNo   = sdr["ContactNo"].ToString();
                userList.Add(user);
            }
            dcc.CloseConnection();
            return(userList);
        }
Пример #4
0
 public bool Update(int updateQuantity, string itemName)
 {
     try
     {
         string query = "UPDATE SelectedItem SET ItemQuantity = " + updateQuantity + " where ItemName = '" + itemName + "' ";
         DataBaseConnectionClass dcc = new DataBaseConnectionClass();
         dcc.ConnectWithDB();
         dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #5
0
 public bool Update(User user)
 {
     try
     {
         string query = "UPDATE UserInfo SET userName = '******' , Password = '******', Designation = '" + user.Designation + "',Salary = " + user.Salary + " , UserType = '" + user.UserType + "', ContactNo = '" + user.ContactNo + "' WHERE userId = '" + user.UserId + "'";
         DataBaseConnectionClass dcc = new DataBaseConnectionClass();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #6
0
 public bool Insert(Menue menu)
 {
     try
     {
         string query = "INSERT into MenuInfo VALUES ('" + menu.MenuId + "', '" + menu.MenuName + "','" + menu.MenuCatagory + "','" + menu.MenuType + "') ";
         DataBaseConnectionClass dcc = new DataBaseConnectionClass();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #7
0
        public bool Insert(OrderMenu order)
        {
            try
            {
                string query = "INSERT into SelectedItem VALUES ('" + order.ItemName + "'," + order.ItemQuantity + "," + "(select ItemPrice from Inventroy where ItemName = '" + order.ItemName + "' )" + ") ";
                DataBaseConnectionClass dcc = new DataBaseConnectionClass();
                dcc.ConnectWithDB();
                dcc.ExecuteSQL(query);
                dcc.CloseConnection();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #8
0
        public bool Delete(string ItemName)
        {
            try
            {
                string query = "DELETE From SelectedItem WHERE ItemName = '" + ItemName + "' ";
                DataBaseConnectionClass dcc = new DataBaseConnectionClass();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #9
0
        public bool Delete(string userId)
        {
            try
            {
                string query = "DELETE From UserInfo WHERE userId = '" + userId + "' ";
                DataBaseConnectionClass dcc = new DataBaseConnectionClass();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #10
0
        public bool Insert(Inventory inventory)
        {
            try
            {
                string query = "Insert into Inventroy VALUES('" + inventory.ItemId + "','" + inventory.ItemName + "'," + inventory.ItemQuantity + "," + inventory.ItemPrice + ")";


                DataBaseConnectionClass dcc = new DataBaseConnectionClass();
                dcc.ConnectWithDB();
                int x = dcc.ExecuteSQL(query);
                dcc.CloseConnection();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #11
0
 public bool Insert(User user)
 {
     try
     {
         string query = "INSERT into UserInfo VALUES ('" + user.UserId + "', '" + user.UserName + "'," +
                        " '" + user.DateOfBirth + "','" + user.Password + "','" + user.Designation + "'," +
                        " " + user.Salary + ",'" + user.UserType + "','" + DateTime.Now + "','" + user.Salary + "')";
         DataBaseConnectionClass dcc = new DataBaseConnectionClass();
         dcc.ConnectWithDB();
         int x = dcc.ExecuteSQL(query);
         dcc.CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #12
0
        public bool ResetSelectedItem()
        {
            try
            {
                string query = "DELETE From SelectedItem";
                DataBaseConnectionClass dcc = new DataBaseConnectionClass();
                dcc.ConnectWithDB();
                dcc.ExecuteSQL(query);

                dcc.CloseConnection();
                dcc.ConnectWithDB();

                dcc.ExecuteSQL("DBCC CHECKIDENT ('[SelectedItem]', RESEED, 0)");
                dcc.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #13
0
        public List <OrderMenu> GetAllOrderMenu()
        {
            string           query         = "SELECT * from SelectedItem";
            List <OrderMenu> orderMenuList = new List <OrderMenu>();

            DataBaseConnectionClass dcc = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                OrderMenu orderMenu = new OrderMenu();
                orderMenu.OrderNo      = Convert.ToInt32(sdr["OrderNo"].ToString());
                orderMenu.ItemName     = sdr["ItemName"].ToString();
                orderMenu.ItemQuantity = Convert.ToInt32(sdr["ItemQuantity"]);
                orderMenu.ItemPrice    = Convert.ToDouble(sdr["ItemPrice"]);
                orderMenuList.Add(orderMenu);
            }
            dcc.CloseConnection();
            return(orderMenuList);
        }
Пример #14
0
        public List <Inventory> GetAllInventory()
        {
            string                  query         = "SELECT * from Inventroy";
            List <Inventory>        inventoryList = new List <Inventory>();
            DataBaseConnectionClass dcc           = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                Inventory inventory = new Inventory();
                inventory.ItemId       = sdr["ItemId"].ToString();
                inventory.ItemName     = sdr["ItemName"].ToString();
                inventory.ItemQuantity = Convert.ToInt32(sdr["ItemQuantity"]);
                inventory.ItemPrice    = Convert.ToDouble(sdr["ItemPrice"]);

                inventoryList.Add(inventory);
            }
            dcc.CloseConnection();
            return(inventoryList);
        }
Пример #15
0
        public List <Menue> GetItem(string menuId)
        {
            string       query    = "SELECT * from MenuInfo where MenuID = '" + menuId + "'";
            List <Menue> menuList = new List <Menue>();

            DataBaseConnectionClass dcc = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            SqlDataReader sdr = dcc.GetData(query);

            while (sdr.Read())
            {
                Menue menu = new Menue();
                menu.MenuId       = sdr["MenuID"].ToString();
                menu.MenuName     = sdr["MenuName"].ToString();
                menu.MenuCatagory = sdr["MenuCatagory"].ToString();
                menu.MenuType     = sdr["MenuType"].ToString();
                menuList.Add(menu);
            }
            dcc.CloseConnection();
            return(menuList);
        }
Пример #16
0
        public bool ItemUpdate(Inventory inventory)
        {
            string query = "UPDATE Inventroy SET ItemQuantity = " + inventory.ItemQuantity + " , ItemName = '" + inventory.ItemName + "' ,ItemPrice = " + inventory.ItemPrice + " where ItemId ='" + inventory.ItemId + "' ";
            DataBaseConnectionClass dcc = new DataBaseConnectionClass();

            dcc.ConnectWithDB();
            dcc.ExecuteSQL(query);
            dcc.CloseConnection();
            return(true);

            /*    try
             *  {
             *      string query = "UPDATE Inventroy SET ItemQuantity = " + inventory.ItemQuantity + " , ItemName = '" + inventory.ItemName + "' ,ItemPrice = " + inventory.ItemPrice + " where ItemId ='" + inventory.ItemId + "' ";
             *      DataBaseConnectionClass dcc = new DataBaseConnectionClass();
             *      dcc.ConnectWithDB();
             *      dcc.ExecuteSQL(query);
             *      dcc.CloseConnection();
             *      return true;
             *  }
             *  catch (Exception ex)
             *  {
             *      return false;
             *  }*/
        }