Esempio n. 1
0
        public int UpdateBasicInfo(EShop.Model.Account_User objUser, EShop.Model.Account_UserDetails objUserDetails)
        {
            Account_User  dalUser = new Account_User();
            SqlConnection conn    = new SqlConnection(DbHelperSQL.connectionString);

            conn.Open();
            SqlTransaction tran = null;

            try
            {
                tran = conn.BeginTransaction();
                if (dalUser.Update(objUser))
                {
                    if (Exists(objUserDetails.Id))
                    {
                        Update(objUserDetails);
                        return(1);
                    }
                    else
                    {
                        Add(objUserDetails);
                        return(1);
                    }
                }
                tran.Commit();
            }
            catch (Exception)
            {
                tran.Rollback();
            }
            return(-1);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(EShop.Model.Account_User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Account_User set ");
            strSql.Append("Password=@Password,");
            strSql.Append("Status=@Status");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Password",    SqlDbType.VarChar, 50),
                new SqlParameter("@Status",      SqlDbType.Int,      4),
                new SqlParameter("@Id",          SqlDbType.Int,      4),
                new SqlParameter("@UserCode",    SqlDbType.VarChar, 50),
                new SqlParameter("@AccountName", SqlDbType.VarChar, 50),
                new SqlParameter("@Email",       SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Password;
            parameters[1].Value = model.Status;
            parameters[2].Value = model.Id;
            parameters[3].Value = model.UserCode;
            parameters[4].Value = model.AccountName;
            parameters[5].Value = model.Email;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public EShop.Model.Account_User DataRowToModel(DataRow row)
 {
     EShop.Model.Account_User model = new EShop.Model.Account_User();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["UserCode"] != null)
         {
             model.UserCode = row["UserCode"].ToString();
         }
         if (row["AccountName"] != null)
         {
             model.AccountName = row["AccountName"].ToString();
         }
         if (row["Email"] != null)
         {
             model.Email = row["Email"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(EShop.Model.Account_User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Account_User(");
            strSql.Append("UserCode,AccountName,Email,Password,Status)");
            strSql.Append(" values (");
            strSql.Append("@UserCode,@AccountName,@Email,@Password,@Status)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",    SqlDbType.VarChar, 50),
                new SqlParameter("@AccountName", SqlDbType.VarChar, 50),
                new SqlParameter("@Email",       SqlDbType.VarChar, 50),
                new SqlParameter("@Password",    SqlDbType.VarChar, 50),
                new SqlParameter("@Status",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserCode;
            parameters[1].Value = model.AccountName;
            parameters[2].Value = model.Email;
            parameters[3].Value = model.Password;
            parameters[4].Value = model.Status;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EShop.Model.Account_User GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserCode,AccountName,Email,Password,Status from Account_User ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            EShop.Model.Account_User model = new EShop.Model.Account_User();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }