日期:2014-05-18  浏览次数:20968 次

谁能用公司C#编程规范修改下此文档,并且注释下!
老说说我们写的代码不规范,到外面根本不行,要重写!请大家帮帮忙!给我修改下!
C# code

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

using QHF.ESF.Model;


namespace QHF.ESF.DAL
{
    public class UserDal
    {

        public static List<UserInfo> GetUsers(int iPageIndex, int iPageSize)
        {
            List<UserInfo> users = new List<UserInfo>();
            StringBuilder sqlString = new StringBuilder();
            sqlString.Append("select top ");
            sqlString.Append(iPageSize.ToString());
            sqlString.Append(" * from es_user ");

            if (iPageIndex > 1)
            {
                sqlString.Append(" where userid not in( select top ");
                sqlString .Append(Utils.IntToStr((iPageIndex-1)*iPageSize));
                sqlString.Append(" userid from es_user)"); 
            }

            SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.connectionString, CommandType.Text, sqlString.ToString(), null);
            while (dr.Read())
            {
                UserInfo ui = new UserInfo();
                ui.id = (int)dr["uid"];
                ui.sex = (((bool)dr["usex"]) == true ? "男" : "女"); 
                ui.userid = (int)dr["userid"];
                ui.name = dr["uname"].ToString();
                ui.mobile = dr["umobile"].ToString();
                ui.phone = dr["uphone"].ToString();
                ui.email = dr["uemail"].ToString();

                users.Add(ui);
            }
            dr.Close();
            return users;
        }

        public static UserInfo GetUser(string userid)
        {
            UserInfo ui;
            StringBuilder sqlString = new StringBuilder();
            sqlString.Append("select  * from es_user ");
            sqlString.Append(" where userid = @userid");

            SqlParameter[] parms = new SqlParameter[]{
                new SqlParameter("@userid", SqlDbType.Int)};

            parms[0].Value = Utils.StrToInt(userid, 0);

            SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.connectionString, CommandType.Text, sqlString.ToString(), parms);
            if (dr.Read())
            {
                ui =  new UserInfo();
                ui.id = (int)dr["uid"];
                ui.sex = (((bool)dr["usex"]) == true ? "男" : "女");
                ui.userid = (int)dr["userid"];
                ui.name = dr["uname"].ToString();
                ui.mobile = dr["umobile"].ToString();
                ui.phone = dr["uphone"].ToString();
                ui.email = dr["uemail"].ToString();
                dr.Close();
            }
            else
            {
                dr.Close();
                StringBuilder sqlIns = new StringBuilder();
                sqlIns.Append("insert into es_user(userid) values(");
                sqlIns.Append("@userid)");
                SqlParameter[] parms1 = new SqlParameter[] { new SqlParameter("@userid",SqlDbType.Int)  };

                parms1[0].Value = Utils.StrToInt(userid, 0);
                int iReturn = SQLHelper.ExecuteNonQuery(SQLHelper.connectionString, CommandType.Text, sqlIns.ToString(), parms1);

                if (iReturn == 1)
                {
                    SqlDataReader dr2 = SQLHelper.ExecuteReader(SQLHelper.connectionString, CommandType.Text, sqlString.ToString(), parms);
                    if (dr2.Read())
                    {
                        ui = new UserInfo();
                        ui.id = (int)dr2["uid"];
                        ui.sex = (((bool)dr2[&