public List <EntityLayers.MenuTypes> AddMenuDDLWCF()
        {
            try
            {
                SqlCommand _cmd = new SqlCommand("select MenuType,MenuTypeID from MenuTypes", _conObj);
                _conObj.Open();
                SqlDataReader dr = _cmd.ExecuteReader();

                List <EntityLayers.MenuTypes> _listObj1 = new List <EntityLayers.MenuTypes>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        EntityLayers.MenuTypes _menuIDObj = new EntityLayers.MenuTypes()
                        {
                            _menuType   = dr[0].ToString(),
                            _menuTypeID = int.Parse(dr[1].ToString())
                        };
                        _listObj1.Add(_menuIDObj);
                    }
                }

                return(_listObj1);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _conObj.Close();
            }
        }
示例#2
0
        public int DeleteMenuType(EntityLayers.MenuTypes obj)
        {
            SqlConnection _conObj = new SqlConnection("Data Source=.;Initial Catalog=HotelDB;Integrated Security=True");
            SqlCommand    _cmd;

            try
            {
                _conObj.Open();
                _cmd    = new SqlCommand("Delete from Menu where MenuTypeID='" + obj._menuTypeID + "'", _conObj);
                _result = _cmd.ExecuteNonQuery();
                return(_result);
            }
            catch (Exception)
            {
                return(2);
            }

            finally
            {
                _conObj.Close();
            }
        }