//ADD MENU method for Admin to ADD MENU ITEMS
        public int AddMenuIns(EntityLayers.Menu _menuObj)
        {
            //Connection String
            //SqlConnection _conObj = new SqlConnection("Data Source=.;Initial Catalog=HotelDB;Integrated Security=True");
            SqlCommand _cmd;

            int _result;

            try
            {
                _conObj.Open();
                _cmd             = new SqlCommand();
                _cmd.CommandText = "sp_AddMenu";
                _cmd.CommandType = CommandType.StoredProcedure;
                _cmd.Connection  = _conObj;
                _cmd.Parameters.AddWithValue("@MenuItem", _menuObj._menuItem);
                _cmd.Parameters.AddWithValue("@MenuTypeID", _menuObj._menuTypeID);
                _cmd.Parameters.AddWithValue("@MenuDesc", _menuObj._menuDescription);
                _cmd.Parameters.AddWithValue("@MenuPrice", _menuObj._menuPrice);


                _result = _cmd.ExecuteNonQuery();

                return(_result);
            }
            catch (Exception)
            {
                throw;
            }

            finally
            {
                _conObj.Close();
            }
        }
        /// <summary>
        /// MEthod for Retreiving values for Drop Down List for displaying Menu ID
        /// </summary>
        /// <returns>Does not return anything</returns>
        public List <EntityLayers.Menu> ModifyMenu()
        {
            SqlConnection _conobj = new SqlConnection(constr);

            try
            {
                SqlCommand _cmd = new SqlCommand("select MenuID from Menu", _conobj);
                _conobj.Open();
                SqlDataReader dr = _cmd.ExecuteReader();

                List <EntityLayers.Menu> _modifyMenuObj = new List <EntityLayers.Menu>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.Menu _menuObj = new EntityLayers.Menu()
                        {
                            _menuID = int.Parse(dr[0].ToString())
                        };
                        _modifyMenuObj.Add(_menuObj);
                    }
                }
                return(_modifyMenuObj);
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                _conobj.Close();
            }
        }
        /// <summary>
        /// Method for Retreiving Values for Modifying Menu
        /// </summary>
        /// <param name="a">Accepts MenuID as parameter</param>
        /// <returns></returns>
        public List <EntityLayers.Menu> RetreiveModifyMenu(string a)
        {
            SqlConnection _conobj = new SqlConnection(constr);
            int           id      = int.Parse(a);

            try
            {
                SqlCommand _cmd = new SqlCommand("select MenuItem,[Description], Price from Menu where MenuID = " + id, _conobj);
                _conobj.Open();
                SqlDataReader dr = _cmd.ExecuteReader();

                List <EntityLayers.Menu> _menuObj = new List <EntityLayers.Menu>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.Menu _modifyMenu = new EntityLayers.Menu()
                        {
                            _menuItem        = dr.GetString(0),
                            _menuDescription = dr.GetString(1),
                            _menuPrice       = dr.GetDecimal(2)
                        };
                        _menuObj.Add(_modifyMenu);
                    }
                }
                return(_menuObj);
            }

            catch (SqlException)
            {
                throw;
            }
            finally
            {
                _conobj.Close();
            }
        }
Пример #4
0
 /// <summary>
 /// Modifying Menu to MenuTable using LINQ TO SQL CONCEPT
 /// </summary>
 /// <param name="_menuObj">It accepts Menu object and returns void</param>
 public void ModifyRoomLinqToSql(EntityLayers.Menu _menuObj)
 {
     DataAccessLayer.MenuDataContext _menuDataContext = new DataAccessLayer.MenuDataContext();
     _menuDataContext.sp_ModifyMenu(_menuObj._menuID, _menuObj._menuItem, _menuObj._menuDescription, _menuObj._menuPrice);
 }