コード例 #1
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        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
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override DataSet ExecSqlDataSet(string sql)
        {
            SqlService _sqlservice = new SqlService(connectionString);

            try
            {
                return(_sqlservice.ExecuteSqlDataSet(sql));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #3
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override void ExecSql(string sql)
        {
            SqlService _sqlservice = new SqlService(connectionString);

            try
            {
                _sqlservice.ExecuteSql(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #4
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override int InsertObjectReturn(object obj, string spName)
        {
            SqlService _sqlservice = new SqlService(connectionString);
            string     sql         = spName;

            foreach (PropertyInfo propertyinfo in obj.GetType().GetProperties())
            {
                if (propertyinfo.PropertyType.ToString() == "System.DateTime")
                {
                    if ((DateTime)propertyinfo.GetValue(obj, null) == DateTime.MinValue || (DateTime)propertyinfo.GetValue(obj, null) == DateTime.MaxValue)
                    {
                        _sqlservice.AddParameter(new SqlParameter("@" + propertyinfo.Name, DBNull.Value));
                    }
                    else
                    {
                        _sqlservice.AddParameter(new SqlParameter("@" + propertyinfo.Name, propertyinfo.GetValue(obj, null)));
                    }
                }
                else
                {
                    _sqlservice.AddParameter(new SqlParameter("@" + propertyinfo.Name, propertyinfo.GetValue(obj, null)));
                }
            }
            SqlParameter paraOutput = new SqlParameter("@ReturnValue", SqlDbType.Int);

            paraOutput.Value     = 0;
            paraOutput.Direction = ParameterDirection.Output;
            _sqlservice.AddParameter(paraOutput);
            try
            {
                _sqlservice.ExecuteSP(sql);
                return((int)paraOutput.Value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #5
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override void Insert_T_Event_Category_From_T_Event_Category(int news_id)
        {
            string     _sql        = "[Insert_T_Event_Category_From_T_Event_Category]";
            SqlService _sqlservice = new SqlService();

            try
            {
                _sqlservice.AddParameter("@ID", SqlDbType.Int, news_id, true);

                _sqlservice.ExecuteSP(_sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #6
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        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();
            }
        }
コード例 #7
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        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();
            }
        }
コード例 #8
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override void Insert_T_CategoryChuyenDe_From_T_CategoryChuyenDe(int news_id, int copyfrom)
        {
            string     _sql        = "[Insert_T_CategoryChuyenDe_From_T_CategoryChuyenDe]";
            SqlService _sqlservice = new SqlService();

            try
            {
                _sqlservice.AddParameter("@ID", SqlDbType.Int, news_id, true);
                _sqlservice.AddParameter("@CopyFrom", SqlDbType.Int, copyfrom, true);

                _sqlservice.ExecuteSP(_sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #9
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override void Insert_T_NewsEvent_Content_From_T_NewsEvent_Content(int news_id, int _CopyFrom)
        {
            string     _sql        = "Insert_T_NewsEvent_Content_From_T_NewsEvent_Content";
            SqlService _sqlservice = new SqlService();

            try
            {
                _sqlservice.AddParameter("@ID", SqlDbType.Int, news_id, true);
                _sqlservice.AddParameter("@Copyfrom", SqlDbType.Int, _CopyFrom, true);

                _sqlservice.ExecuteSP(_sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #10
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override DataSet GetDataSet(string TableName, string ColumnList, string Where)
        {
            string     _sql        = "Sp_GetColumnValues";
            SqlService _sqlservice = new SqlService(connectionString);

            _sqlservice.AddParameter("@TableName", SqlDbType.NVarChar, TableName);
            _sqlservice.AddParameter("@ColumnList", SqlDbType.NVarChar, ColumnList);
            _sqlservice.AddParameter("@Where", SqlDbType.NVarChar, Where);
            try
            {
                return(_sqlservice.ExecuteSPDataSet(_sql));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #11
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        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();
            }
        }
コード例 #12
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override void ExecStore(string StoreName, string[] param1, object[] value)
        {
            string     _sql        = StoreName;
            SqlService _sqlservice = new SqlService(connectionString);

            for (int i = 0; i < param1.Length; i++)
            {
                _sqlservice.AddParameter(new SqlParameter(param1[i], value[i]));
            }
            try
            {
                _sqlservice.ExecuteSP(_sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }
コード例 #13
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        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);
        }
コード例 #14
0
ファイル: BaseClass.cs プロジェクト: tungdang130991/MyGit
        public override void InsertObject(object obj)
        {
            SqlService _sqlservice = new SqlService(connectionString);
            string     sql         = "Sp_Insert" + obj.GetType().Name;

            foreach (PropertyInfo propertyinfo in obj.GetType().GetProperties())
            {
                if (propertyinfo.PropertyType.ToString() == "System.DateTime")
                {
                    if ((DateTime)propertyinfo.GetValue(obj, null) == DateTime.MinValue || (DateTime)propertyinfo.GetValue(obj, null) == DateTime.MaxValue)
                    {
                        _sqlservice.AddParameter(new SqlParameter("@" + propertyinfo.Name, DBNull.Value));
                    }
                    else
                    {
                        _sqlservice.AddParameter(new SqlParameter("@" + propertyinfo.Name, propertyinfo.GetValue(obj, null)));
                    }
                }
                else
                {
                    _sqlservice.AddParameter(new SqlParameter("@" + propertyinfo.Name, propertyinfo.GetValue(obj, null)));
                }
            }
            try
            {
                _sqlservice.ExecuteSP(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _sqlservice.Disconnect();
            }
        }