Example #1
0
 /// <summary>
 /// 得到用户列表
 /// </summary>
 /// <param name="PageIndex"></param>
 /// <param name="PageNum"></param>
 /// <param name="where"></param>
 /// <param name="Count"></param>
 /// <returns></returns>
 public string GetDealerModelList(int PageIndex, int PageNum, int?DealerId, string CompanyName, out int Count, out List <DealerModel> olist)
 {
     olist        = new List <DealerModel>();
     Count        = 0;
     string where = " 1=1";
     if (DealerId != null)
     {
         where += " and DealerInfo.AdminId=" + DealerId.Value;
     }
     if (!String.IsNullOrEmpty(CompanyName))
     {
         where += " and DealerInfo.DealerCompanyName like '%" + CompanyName + "%'";
     }
     try
     {
         olist = dd.GetDealerModelList(PageIndex, PageNum, where, out Count);
         return(Config.Success);
     }
     catch (Exception ex)
     {
         WriteLog.WriteExceptionLog("ZB.BLL.Authorization.AdminBLL.GetDealerModelList()", ex);
         return(Config.ExceptionMsg);
     }
 }
Example #2
0
    /// <summary>
    /// 得到用户列表
    /// </summary>
    /// <param name="PageIndex"></param>
    /// <param name="PageNum"></param>
    /// <param name="where"></param>
    /// <param name="Count"></param>
    /// <returns></returns>
    public List <AdminModel> GetAdminList(int PageIndex, int PageNum, string where, out int Count)
    {
        List <AdminModel> olist = new List <AdminModel>();

        Count = 0;
        SqlConnection sqlConnection = new SqlConnection(Config.ConnectionString);
        SqlCommand    sqlcommand    = new SqlCommand("sp_AdminList", sqlConnection);

        sqlcommand.CommandType = CommandType.StoredProcedure;

        SqlParameter _PageIndex = new SqlParameter("@PageIndex", PageIndex);

        _PageIndex.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_PageIndex);

        SqlParameter _PageNum = new SqlParameter("@PageNum", PageNum);

        _PageNum.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_PageNum);

        SqlParameter _where = new SqlParameter("@where", where);

        _where.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_where);

        SqlParameter _Count = new SqlParameter("@Count", SqlDbType.Int);

        _Count.Direction = ParameterDirection.Output;
        sqlcommand.Parameters.Add(_Count);
        try
        {
            sqlConnection.Open();
            using (IDataReader idr = sqlcommand.ExecuteReader())
            {
                DealerDAL      dd   = new DealerDAL();
                StoreDAL       sd   = new StoreDAL();
                PermissionsDAL pDal = new PermissionsDAL();
                while (idr.Read())
                {
                    AdminModel oCModel = new AdminModel();
                    if (idr["AdminId"] != DBNull.Value)
                    {
                        oCModel.AdminId = (int)idr["AdminId"];
                    }
                    if (idr["AdminName"] != DBNull.Value)
                    {
                        oCModel.AdminName = (string)idr["AdminName"];
                    }
                    if (idr["AdminPassword"] != DBNull.Value)
                    {
                        oCModel.AdminPassword = (string)idr["AdminPassword"];
                    }
                    if (idr["Type"] != DBNull.Value)
                    {
                        oCModel.Type = (AdminType)idr["Type"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        oCModel.RoleId = (int)idr["RoleId"];
                    }
                    if (idr["Status"] != DBNull.Value)
                    {
                        oCModel.Status = (bool)idr["Status"];
                    }
                    if (idr["CreateTime"] != DBNull.Value)
                    {
                        oCModel.CreateTime = (DateTime)idr["CreateTime"];
                    }

                    if (idr["CreatorId"] != DBNull.Value)
                    {
                        oCModel.CreatorId = (int)idr["CreatorId"];
                    }
                    int Totoal = 0;
                    List <DealerModel> dModel = dd.GetDealerModelList(1, 1, "DealerInfo.AdminId=" + oCModel.AdminId, out Totoal);
                    if (dModel != null & dModel.Count > 0)
                    {
                        oCModel.Dealer = dModel[0];
                    }
                    List <StoreModel> oSMoel = sd.GetStoreModelList(1, 1, "StoreInfo.AdminId=" + oCModel.AdminId, out Totoal);
                    if (oSMoel != null & oSMoel.Count > 0)
                    {
                        oCModel.Store = oSMoel[0];
                    }
                    RoleModel role = new RoleModel();
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.RoleId = (int)idr["RoleId"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.RoleName = (string)idr["RoleName"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.Permissions = pDal.GetRoleModulePermission(role.RoleId);
                    }
                    oCModel.Role = role;
                    olist.Add(oCModel);
                }
            }
            Count = int.Parse(_Count.Value.ToString());
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            sqlConnection.Close();
        }
        return(olist);
    }