예제 #1
0
        public HG_Category GetOne(int CategoryID)
        {
            SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

            Con.Open();
            SqlCommand    cmd    = null;
            SqlDataReader SDR    = null;
            HG_Category   ObjTmp = new HG_Category();

            try
            {
                string Query = "SELECT * FROM  HG_Category where CategoryID=@CategoryID";
                cmd = new SqlCommand(Query, Con);
                cmd.Parameters.AddWithValue("@CategoryID", CategoryID);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp.CategoryID   = SDR.GetInt32(0);
                    ObjTmp.OrgID        = SDR.GetInt32(1);
                    ObjTmp.Category     = SDR.GetString(2);
                    ObjTmp.Status       = SDR.GetBoolean(6);
                    ObjTmp.CategoryType = SDR.GetInt32(7);
                }
            }
            catch (System.Exception e)
            { e.ToString(); }

            finally { Con.Close(); }

            return(ObjTmp);
        }
예제 #2
0
        public List <HG_Category> GetAll(int OrgId = 0, int CategoryType = 1)
        {
            var           CurrOrgID = HttpContext.Current.Request.Cookies["UserInfo"];
            SqlConnection Con       = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

            Con.Open();
            SqlCommand         cmd     = null;
            SqlDataReader      SDR     = null;
            List <HG_Category> ListTmp = new List <HG_Category>();
            string             Query   = "SELECT * FROM  HG_Category where CategoryType=" + CategoryType.ToString() + "  ORDER BY CategoryID DESC";

            if (OrgId > 0)
            {
                Query = "SELECT * FROM  HG_Category where OrgID=" + OrgId.ToString() + " and CategoryType=" + CategoryType.ToString() + " ORDER BY CategoryID DESC";
            }
            else if (CurrOrgID != null && int.Parse(CurrOrgID["OrgId"]) > 0)
            {
                Query = "SELECT * FROM  HG_Category where OrgID=" + CurrOrgID["OrgId"] + "and CategoryType=" + CategoryType.ToString() + " ORDER BY CategoryID DESC";
            }
            try
            {
                cmd = new SqlCommand(Query, Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    HG_Category ObjTmp = new HG_Category();
                    ObjTmp.CategoryID   = SDR.GetInt32(0);
                    ObjTmp.OrgID        = SDR.GetInt32(1);
                    ObjTmp.Category     = SDR.GetString(2);
                    ObjTmp.Status       = SDR.GetBoolean(6);
                    ObjTmp.CategoryType = SDR.GetInt32(7);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { Con.Close(); }

            return(ListTmp);
        }