Example #1
0
        public static OrderMenuCategory GetOne(int Id)
        {
            DBCon             dBCon  = new DBCon();
            SqlCommand        cmd    = null;
            SqlDataReader     SDR    = null;
            OrderMenuCategory ObjTmp = new OrderMenuCategory();
            string            Query  = "SELECT * FROM  OrdMenuCategory where Id=" + Id.ToString() + " ";

            try
            {
                cmd = new SqlCommand(Query, dBCon.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    int index = 0;
                    ObjTmp.id          = SDR.GetInt32(index++);
                    ObjTmp.CategoryId  = SDR.GetInt32(index++);
                    ObjTmp.DisplayName = SDR.GetString(index++);
                    ObjTmp.OrderNo     = SDR.GetInt32(index++);
                    ObjTmp.OrderMenuid = SDR.GetInt32(index++);
                    ObjTmp.Status      = SDR.GetBoolean(index++);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally
            {
                dBCon.Con.Close();
                if (!SDR.IsClosed)
                {
                    SDR.Close();
                }
            }
            return(ObjTmp);
        }
Example #2
0
        public static List <OrderMenuCategory> GetAll(int OderMenuId = 0, int CategoryId = 0, int Id = 0)
        {
            SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

            Con.Open();
            SqlCommand               cmd     = null;
            SqlDataReader            SDR     = null;
            List <OrderMenuCategory> ListTmp = new List <OrderMenuCategory>();
            string Query = "SELECT * FROM  OrdMenuCategory where OrderMenuId=" + OderMenuId.ToString() + " ";

            if (CategoryId > 0)
            {
                Query = "SELECT * FROM  OrdMenuCategory where CategoryId=" + CategoryId.ToString() + " ";
            }
            try
            {
                cmd = new SqlCommand(Query, Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    int index = 0;
                    OrderMenuCategory ObjTmp = new OrderMenuCategory();
                    ObjTmp.id          = SDR.GetInt32(index++);
                    ObjTmp.CategoryId  = SDR.GetInt32(index++);
                    ObjTmp.DisplayName = SDR.GetString(index++);
                    ObjTmp.OrderNo     = SDR.GetInt32(index++);
                    ObjTmp.OrderMenuid = SDR.GetInt32(index++);
                    ObjTmp.Status      = SDR.GetBoolean(index++);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally
            {
                Con.Close();
                if (!SDR.IsClosed)
                {
                    SDR.Close();
                }
            }

            return(ListTmp);
        }