Beispiel #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public long Add(JY.Model.Member model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.BigInt,     8),
                new SqlParameter("@MemberRankId", SqlDbType.Int,        4),
                new SqlParameter("@MemberName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Password",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Email",        SqlDbType.NVarChar,  50),
                new SqlParameter("@Phone",        SqlDbType.NVarChar,  50),
                new SqlParameter("@QQ",           SqlDbType.NVarChar,  50),
                new SqlParameter("@Address",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Remark",       SqlDbType.NText),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@IsDelete",     SqlDbType.Bit, 1)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.MemberRankId;
            parameters[2].Value     = model.MemberName;
            parameters[3].Value     = model.Password;
            parameters[4].Value     = model.Email;
            parameters[5].Value     = model.Phone;
            parameters[6].Value     = model.QQ;
            parameters[7].Value     = model.Address;
            parameters[8].Value     = model.Remark;
            parameters[9].Value     = model.CreateDate;
            parameters[10].Value    = model.IsDelete;

            DbHelperSQL.RunProcedure("Member_ADD", parameters, out rowsAffected);
            return((long)parameters[0].Value);
        }
Beispiel #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(JY.Model.Member model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.BigInt,     8),
                new SqlParameter("@MemberRankId", SqlDbType.Int,        4),
                new SqlParameter("@MemberName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Password",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Email",        SqlDbType.NVarChar,  50),
                new SqlParameter("@Phone",        SqlDbType.NVarChar,  50),
                new SqlParameter("@QQ",           SqlDbType.NVarChar,  50),
                new SqlParameter("@Address",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Remark",       SqlDbType.NText),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@IsDelete",     SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.MemberRankId;
            parameters[2].Value  = model.MemberName;
            parameters[3].Value  = model.Password;
            parameters[4].Value  = model.Email;
            parameters[5].Value  = model.Phone;
            parameters[6].Value  = model.QQ;
            parameters[7].Value  = model.Address;
            parameters[8].Value  = model.Remark;
            parameters[9].Value  = model.CreateDate;
            parameters[10].Value = model.IsDelete;

            DbHelperSQL.RunProcedure("Member_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JY.Model.Member GetModel(long ID)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            JY.Model.Member model = new JY.Model.Member();
            DataSet         ds    = DbHelperSQL.RunProcedure("Member_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberRankId"] != null && ds.Tables[0].Rows[0]["MemberRankId"].ToString() != "")
                {
                    model.MemberRankId = int.Parse(ds.Tables[0].Rows[0]["MemberRankId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberName"] != null && ds.Tables[0].Rows[0]["MemberName"].ToString() != "")
                {
                    model.MemberName = ds.Tables[0].Rows[0]["MemberName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Password"] != null && ds.Tables[0].Rows[0]["Password"].ToString() != "")
                {
                    model.Password = ds.Tables[0].Rows[0]["Password"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Email"] != null && ds.Tables[0].Rows[0]["Email"].ToString() != "")
                {
                    model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Phone"] != null && ds.Tables[0].Rows[0]["Phone"].ToString() != "")
                {
                    model.Phone = ds.Tables[0].Rows[0]["Phone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["QQ"] != null && ds.Tables[0].Rows[0]["QQ"].ToString() != "")
                {
                    model.QQ = ds.Tables[0].Rows[0]["QQ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "")
                {
                    model.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsDelete"] != null && ds.Tables[0].Rows[0]["IsDelete"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsDelete"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower() == "true"))
                    {
                        model.IsDelete = true;
                    }
                    else
                    {
                        model.IsDelete = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }