예제 #1
0
        public override T_RolePermission GetRole4UserMenu(int User_ID, int Menu_ID)
        {
            string           _sql        = "Sp_GetRoleForUserMenu";
            SqlService       _sqlservice = new SqlService(connectionString);
            T_RolePermission _role       = new T_RolePermission();
            SqlDataReader    _reader;

            try
            {
                _sqlservice.AddParameter("@User_ID", SqlDbType.Int, User_ID);

                _sqlservice.AddParameter("@Menu_ID", SqlDbType.Int, Menu_ID);
                _reader = _sqlservice.ExecuteSPReader(_sql);
                if (_reader.HasRows)
                {
                    _reader.Read();
                    if (_reader["Doc"] != DBNull.Value)
                    {
                        _role.R_Read = Convert.ToBoolean(_reader["Doc"]);
                    }
                    if (_reader["Ghi"] != DBNull.Value)
                    {
                        _role.R_Write = Convert.ToBoolean(_reader["Ghi"]);
                    }
                    if (_reader["Xoa"] != DBNull.Value)
                    {
                        _role.R_Delete = Convert.ToBoolean(_reader["Xoa"]);
                    }
                    _reader.Close();
                }
                else
                {
                    _role.R_Read   = false;
                    _role.R_Write  = false;
                    _role.R_Delete = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
            return(_role);
        }
예제 #2
0
        public override bool Login(string userName, string passWord)
        {
            string     _sql        = "Sp_UserLogin";
            SqlService _sqlservice = new SqlService(connectionString);

            _sqlservice.AddParameter("@userName", SqlDbType.NVarChar, userName);
            _sqlservice.AddParameter("@passWord", SqlDbType.NVarChar, passWord);
            try
            {
                return(_sqlservice.ExecuteSPReader(_sql).HasRows ? true : false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
예제 #3
0
        public override object GetObjectByID(string sp_name, string Id, string TypeName, string FieldIDName)
        {
            SqlService    _sqlservice = new SqlService(connectionString);
            string        sql         = sp_name;
            SqlDataReader reader;

            _sqlservice.AddParameter(new SqlParameter("@" + FieldIDName, Id));
            try
            {
                reader = _sqlservice.ExecuteSPReader(sql);
                return(CBO.FillObject(reader, Type.GetType("HPCInfo." + TypeName + ",HPCInfo")));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
예제 #4
0
        public override string GetColumnValues(string TableName, string ColumnName, string Where)
        {
            string        _sql        = "Sp_GetColumnValues";
            SqlService    _sqlservice = new SqlService(connectionString);
            SqlDataReader _reader;
            StringBuilder _result = new StringBuilder();
            string        tmp     = string.Empty;

            _sqlservice.AddParameter("@TableName", SqlDbType.NVarChar, TableName);
            _sqlservice.AddParameter("@ColumnList", SqlDbType.NVarChar, ColumnName);
            _sqlservice.AddParameter("@Where", SqlDbType.NVarChar, Where);
            try
            {
                _reader = _sqlservice.ExecuteSPReader(_sql);
                if (_reader.HasRows)
                {
                    while (_reader.Read())
                    {
                        if (_reader[ColumnName] != DBNull.Value)
                        {
                            _result.Append(_reader[ColumnName].ToString() + ";");
                        }
                        else
                        {
                            _result.Append(" ;");
                        }
                    }
                }
                tmp = _result.ToString();
                return(tmp.EndsWith(";") ? tmp.Substring(0, tmp.Length - 1) : tmp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
예제 #5
0
        public override object GetObjectByCondition(string TypeName, string whereCondition)
        {
            object     obj;
            SqlService _sqlservice = new SqlService(connectionString);

            string sql = "SP_GetObjectByCondition";

            try
            {
                _sqlservice.AddParameter("@TypeName", SqlDbType.NVarChar, TypeName);
                _sqlservice.AddParameter("@whereCondition", SqlDbType.NVarChar, whereCondition);
                obj = CBO.FillObject(_sqlservice.ExecuteSPReader(sql), Type.GetType("HPCInfo." + TypeName + ",HPCInfo"));
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
            return(obj);
        }