示例#1
0
        internal static bool ExecuteNonQuery(string sprocName)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(_Connection))
                {
                    SqlCommand cmd = new SqlCommand(sprocName, con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    for (int index = 0; index < _ParamName.Count; index++)
                    {
                        cmd.Parameters.AddWithValue(_ParamName[index], _ParamValue[index]);
                    }

                    con.Open();
                    cmd.ExecuteNonQuery();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                return(false);
            }
            finally
            {
                EmptyParams();
            }
        }
示例#2
0
        internal static DataTable AdapterFill(string sprocName)
        {
            DataTable dataTable = new DataTable();

            try
            {
                using (SqlConnection con = new SqlConnection(_Connection))
                {
                    SqlCommand cmd = new SqlCommand(sprocName, con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    for (int index = 0; index < _ParamName.Count; index++)
                    {
                        cmd.Parameters.AddWithValue(_ParamName[index], _ParamValue[index]);
                    }

                    using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                    {
                        sda.Fill(dataTable);
                    }
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
            }
            finally
            {
                EmptyParams();
            }

            return(dataTable);
        }
示例#3
0
        public override bool UserInfoUpdate(UserInfo user)
        {
            DBCommands.PopulateParams("@UserName", user.UserName);
            DBCommands.PopulateParams("@ProfileImage", user.ProfileImage);
            DBCommands.PopulateParams("@GroupUsers", MapGroupListToTable(user.GroupUsers));

            return(DBCommands.ExecuteNonQuery("p_UserInfo_Update"));
        }
示例#4
0
        internal static string ExecuteScalar(string sprocName)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(_Connection))
                {
                    SqlCommand cmd = new SqlCommand(sprocName, con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    for (int index = 0; index < _ParamName.Count; index++)
                    {
                        cmd.Parameters.AddWithValue(_ParamName[index], _ParamValue[index]);
                    }

                    con.Open();
                    var result = cmd.ExecuteScalar();
                    if (result != null)
                    {
                        return(result.ToString());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                return(null);
            }
            finally
            {
                EmptyParams();
            }
        }
示例#5
0
 public override DataTable UserGroupsGetActive()
 {
     return(DBCommands.AdapterFill("p_UserGroup_GetActive"));
 }
示例#6
0
        public override DataTable GroupUsersGetByUserName(string userName)
        {
            DBCommands.PopulateParams("@UserName", userName);

            return(DBCommands.AdapterFill("p_GroupUsers_GetByUserName"));
        }
示例#7
0
        public override UserInfo UserInfoGetByUser(string userName)
        {
            DBCommands.PopulateParams("@UserName", userName);

            return((UserInfo)DBCommands.DataReader("p_UserInfo_GetByUser", DBCommands.ObjectTypes.UserInfo));
        }
示例#8
0
 public override DataTable UserInfoGetAll()
 {
     return(DBCommands.AdapterFill("p_UserInfo_GetAll"));
 }