Ejemplo n.º 1
0
        public HG_UserTypes GetOne(int UTID = 0, string UserType = null)
        {
            SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

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

            try
            {
                if (UTID > 0)
                {
                    string Query = "SELECT * FROM  HG_UserTypes where UTID=@UTID";
                    cmd = new SqlCommand(Query, Con);
                    cmd.Parameters.AddWithValue("@UTID", UTID);
                }
                else if (UserType != null)
                {
                    string Query = "SELECT * FROM  HG_UserTypes where UserType=@UserType";
                    cmd = new SqlCommand(Query, Con);
                    cmd.Parameters.AddWithValue("@UserType", UserType);
                }
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp.UTID         = SDR.GetInt32(0);
                    ObjTmp.UserType     = SDR.GetString(1);
                    ObjTmp.UserTypeName = SDR.GetString(2);
                    ObjTmp.Status       = SDR.GetBoolean(6);
                }
            }
            catch (System.Exception e)
            { e.ToString(); }

            finally { Con.Close(); }

            return(ObjTmp);
        }
Ejemplo n.º 2
0
        public List <HG_UserTypes> GetAll(bool all = false)
        {
            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_UserTypes> ListTmp = new List <HG_UserTypes>();
            string Query = "SELECT * FROM  HG_UserTypes   ORDER BY UTID DESC";

            if (CurrOrgID != null && int.Parse(CurrOrgID["OrgId"]) > 0 && all == false)
            {
                Query = "SELECT * FROM  HG_UserTypes where UserType!='SA' And UserType!='A' ORDER BY UTID DESC";
            }
            try
            {
                cmd = new SqlCommand(Query, Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    HG_UserTypes ObjTmp = new HG_UserTypes();
                    ObjTmp.UTID         = SDR.GetInt32(0);
                    ObjTmp.UserType     = SDR.GetString(1);
                    ObjTmp.UserTypeName = SDR.GetString(2);
                    ObjTmp.EntryBy      = SDR.GetInt32(3);
                    ObjTmp.EntryDate    = SDR.GetDateTime(4);
                    ObjTmp.UpdateDate   = SDR.GetDateTime(5);
                    ObjTmp.Status       = SDR.GetBoolean(6);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { Con.Close(); }

            return(ListTmp);
        }