예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(Model.UserBase model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserBase(");
            strSql.Append("userId,fullName,regCode,createDate,liveAddress,memAllTotal,organizeCode,artificialName,artificialBodyCode,artificialMobile,status,remark,addTime,addUser,infoType)");
            strSql.Append(" values (");
            strSql.Append("@userId,@fullName,@regCode,@createDate,@liveAddress,@memAllTotal,@organizeCode,@artificialName,@artificialBodyCode,@artificialMobile,@status,@remark,@addTime,@addUser,@infoType)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",             SqlDbType.Int,          4),
                new SqlParameter("@fullName",           SqlDbType.VarChar,    150),
                new SqlParameter("@regCode",            SqlDbType.VarChar,     50),
                new SqlParameter("@createDate",         SqlDbType.VarChar,    150),
                new SqlParameter("@liveAddress",        SqlDbType.VarChar,    150),
                new SqlParameter("@memAllTotal",        SqlDbType.Money,        8),
                new SqlParameter("@organizeCode",       SqlDbType.VarChar,   1500),
                new SqlParameter("@artificialName",     SqlDbType.VarChar,     50),
                new SqlParameter("@artificialBodyCode", SqlDbType.VarChar,     50),
                new SqlParameter("@artificialMobile",   SqlDbType.VarChar,     50),
                new SqlParameter("@status",             SqlDbType.Int,          4),
                new SqlParameter("@remark",             SqlDbType.VarChar,    500),
                new SqlParameter("@addTime",            SqlDbType.DateTime),
                new SqlParameter("@addUser",            SqlDbType.Int,          4),
                new SqlParameter("@infoType",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.userId;
            parameters[1].Value  = model.fullName;
            parameters[2].Value  = model.regCode;
            parameters[3].Value  = model.createDate;
            parameters[4].Value  = model.liveAddress;
            parameters[5].Value  = model.memAllTotal;
            parameters[6].Value  = model.organizeCode;
            parameters[7].Value  = model.artificialName;
            parameters[8].Value  = model.artificialBodyCode;
            parameters[9].Value  = model.artificialMobile;
            parameters[10].Value = model.status;
            parameters[11].Value = model.remark;
            parameters[12].Value = model.addTime;
            parameters[13].Value = model.addUser;
            parameters[14].Value = model.infoType;

            int rows = DBHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            return(rows);
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.UserBase GetModelByUserId(int userId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from UserBase ");
            strSql.Append(" where userId=@userId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId", SqlDbType.Int, 4)
            };
            parameters[0].Value = userId;

            Model.UserBase model = new Model.UserBase();
            DataSet        ds    = DBHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.UserBase DataRowToModel(DataRow row)
        {
            Model.UserBase model = new Model.UserBase();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["userId"] != null && row["userId"].ToString() != "")
                {
                    model.userId = int.Parse(row["userId"].ToString());
                }
                if (row["fullName"] != null)
                {
                    model.fullName = row["fullName"].ToString();
                }
                if (row["regCode"] != null)
                {
                    model.regCode = row["regCode"].ToString();
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = row["createDate"].ToString();
                }
                if (row["liveAddress"] != null)
                {
                    model.liveAddress = row["liveAddress"].ToString();
                }
                if (row["memAllTotal"] != null && row["memAllTotal"].ToString() != "")
                {
                    model.memAllTotal = double.Parse(row["memAllTotal"].ToString());
                }
                if (row["organizeCode"] != null)
                {
                    model.organizeCode = row["organizeCode"].ToString();
                }
                if (row["artificialName"] != null)
                {
                    model.artificialName = row["artificialName"].ToString();
                }
                if (row["artificialBodyCode"] != null)
                {
                    model.artificialBodyCode = row["artificialBodyCode"].ToString();
                }
                if (row["artificialMobile"] != null)
                {
                    model.artificialMobile = row["artificialMobile"].ToString();
                }

                if (row["status"] != null && row["status"].ToString() != "")
                {
                    model.status = int.Parse(row["status"].ToString());
                }
                if (row["remark"] != null)
                {
                    model.remark = row["remark"].ToString();
                }
                if (row["addTime"] != null && row["addTime"].ToString() != "")
                {
                    model.addTime = DateTime.Parse(row["addTime"].ToString());
                }
                if (row["addUser"] != null && row["addUser"].ToString() != "")
                {
                    model.addUser = int.Parse(row["addUser"].ToString());
                }
                if (row["infoType"] != null && row["infoType"].ToString() != "")
                {
                    model.infoType = int.Parse(row["infoType"].ToString());
                }
            }
            return(model);
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static int Update(Model.UserBase model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserBase set ");
            strSql.Append("userId=@userId,");
            strSql.Append("fullName=@fullName,");
            strSql.Append("regCode=@regCode,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("liveAddress=@liveAddress,");
            strSql.Append("memAllTotal=@memAllTotal,");
            strSql.Append("organizeCode=@organizeCode,");
            strSql.Append("artificialName=@artificialName,");
            strSql.Append("artificialBodyCode=@artificialBodyCode,");
            strSql.Append("artificialMobile=@artificialMobile,");
            strSql.Append("status=@status,");
            strSql.Append("remark=@remark,");
            strSql.Append("addTime=@addTime,");
            strSql.Append("addUser=@addUser,");
            strSql.Append("infoType=@infoType");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",             SqlDbType.Int,          4),
                new SqlParameter("@fullName",           SqlDbType.VarChar,    150),
                new SqlParameter("@regCode",            SqlDbType.VarChar,     50),
                new SqlParameter("@createDate",         SqlDbType.VarChar,    150),
                new SqlParameter("@liveAddress",        SqlDbType.VarChar,    150),
                new SqlParameter("@memAllTotal",        SqlDbType.Money,        8),
                new SqlParameter("@organizeCode",       SqlDbType.VarChar,   1500),
                new SqlParameter("@artificialName",     SqlDbType.VarChar,     50),
                new SqlParameter("@artificialBodyCode", SqlDbType.VarChar,     50),
                new SqlParameter("@artificialMobile",   SqlDbType.VarChar,     50),

                new SqlParameter("@status",             SqlDbType.Int,          4),
                new SqlParameter("@remark",             SqlDbType.VarChar,    500),
                new SqlParameter("@addTime",            SqlDbType.DateTime),
                new SqlParameter("@addUser",            SqlDbType.Int,          4),
                new SqlParameter("@infoType",           SqlDbType.Int,          4),
                new SqlParameter("@id",                 SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.userId;
            parameters[1].Value  = model.fullName;
            parameters[2].Value  = model.regCode;
            parameters[3].Value  = model.createDate;
            parameters[4].Value  = model.liveAddress;
            parameters[5].Value  = model.memAllTotal;
            parameters[6].Value  = model.organizeCode;
            parameters[7].Value  = model.artificialName;
            parameters[8].Value  = model.artificialBodyCode;
            parameters[9].Value  = model.artificialMobile;
            parameters[10].Value = model.status;
            parameters[11].Value = model.remark;
            parameters[12].Value = model.addTime;
            parameters[13].Value = model.addUser;
            parameters[14].Value = model.infoType;
            parameters[15].Value = model.id;

            int rows = DBHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            return(rows);
        }