Ejemplo 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(EShop.Model.Account_UserDetails model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Account_UserDetails set ");
            strSql.Append("UserCode=@UserCode,");
            strSql.Append("Birthday=@Birthday,");
            strSql.Append("Gender=@Gender,");
            strSql.Append("OfficeTEL=@OfficeTEL,");
            strSql.Append("FamilyTEL=@FamilyTEL,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("PwdTipCode=@PwdTipCode,");
            strSql.Append("PwdTipAns=@PwdTipAns");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",   SqlDbType.VarChar, 50),
                new SqlParameter("@Birthday",   SqlDbType.Date,     3),
                new SqlParameter("@Gender",     SqlDbType.Int,      4),
                new SqlParameter("@OfficeTEL",  SqlDbType.VarChar, 15),
                new SqlParameter("@FamilyTEL",  SqlDbType.VarChar, 15),
                new SqlParameter("@Phone",      SqlDbType.VarChar, 20),
                new SqlParameter("@PwdTipCode", SqlDbType.VarChar, 50),
                new SqlParameter("@PwdTipAns",  SqlDbType.VarChar, 50),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserCode;
            parameters[1].Value = model.Birthday;
            parameters[2].Value = model.Gender;
            parameters[3].Value = model.OfficeTEL;
            parameters[4].Value = model.FamilyTEL;
            parameters[5].Value = model.Phone;
            parameters[6].Value = model.PwdTipCode;
            parameters[7].Value = model.PwdTipAns;
            parameters[8].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public EShop.Model.Account_UserDetails DataRowToModel(DataRow row)
 {
     EShop.Model.Account_UserDetails model = new EShop.Model.Account_UserDetails();
     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["Birthday"] != null && row["Birthday"].ToString() != "")
         {
             model.Birthday = DateTime.Parse(row["Birthday"].ToString());
         }
         if (row["Gender"] != null && row["Gender"].ToString() != "")
         {
             model.Gender = int.Parse(row["Gender"].ToString());
         }
         if (row["OfficeTEL"] != null)
         {
             model.OfficeTEL = row["OfficeTEL"].ToString();
         }
         if (row["FamilyTEL"] != null)
         {
             model.FamilyTEL = row["FamilyTEL"].ToString();
         }
         if (row["Phone"] != null)
         {
             model.Phone = row["Phone"].ToString();
         }
         if (row["PwdTipCode"] != null)
         {
             model.PwdTipCode = row["PwdTipCode"].ToString();
         }
         if (row["PwdTipAns"] != null)
         {
             model.PwdTipAns = row["PwdTipAns"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(EShop.Model.Account_UserDetails model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Account_UserDetails(");
            strSql.Append("UserCode,Birthday,Gender,OfficeTEL,FamilyTEL,Phone,PwdTipCode,PwdTipAns)");
            strSql.Append(" values (");
            strSql.Append("@UserCode,@Birthday,@Gender,@OfficeTEL,@FamilyTEL,@Phone,@PwdTipCode,@PwdTipAns)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",   SqlDbType.VarChar, 50),
                new SqlParameter("@Birthday",   SqlDbType.Date,     3),
                new SqlParameter("@Gender",     SqlDbType.Int,      4),
                new SqlParameter("@OfficeTEL",  SqlDbType.VarChar, 15),
                new SqlParameter("@FamilyTEL",  SqlDbType.VarChar, 15),
                new SqlParameter("@Phone",      SqlDbType.VarChar, 20),
                new SqlParameter("@PwdTipCode", SqlDbType.VarChar, 50),
                new SqlParameter("@PwdTipAns",  SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.UserCode;
            parameters[1].Value = model.Birthday;
            parameters[2].Value = model.Gender;
            parameters[3].Value = model.OfficeTEL;
            parameters[4].Value = model.FamilyTEL;
            parameters[5].Value = model.Phone;
            parameters[6].Value = model.PwdTipCode;
            parameters[7].Value = model.PwdTipAns;

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

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

            strSql.Append("select  top 1 Id,UserCode,Birthday,Gender,OfficeTEL,FamilyTEL,Phone,PwdTipCode,PwdTipAns from Account_UserDetails ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

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