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

            strSql.Append("insert into EUser(");
            strSql.Append("UserName,PassWord,Email,Name,Sex,Age,ID_Card,Phone,MobilPhone,Address,Postalcode,Work,Income,Integral,CreateTime,LaseLogin)");
            strSql.Append(" values (");
            strSql.Append("@UserName,@PassWord,@Email,@Name,@Sex,@Age,@ID_Card,@Phone,@MobilPhone,@Address,@Postalcode,@Work,@Income,@Integral,@CreateTime,@LaseLogin)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@PassWord",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Email",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Name",       SqlDbType.NVarChar,  20),
                new SqlParameter("@Sex",        SqlDbType.Char,       4),
                new SqlParameter("@Age",        SqlDbType.Int,        4),
                new SqlParameter("@ID_Card",    SqlDbType.NVarChar,  18),
                new SqlParameter("@Phone",      SqlDbType.NVarChar,  30),
                new SqlParameter("@MobilPhone", SqlDbType.NVarChar,  30),
                new SqlParameter("@Address",    SqlDbType.NVarChar),
                new SqlParameter("@Postalcode", SqlDbType.NVarChar,  10),
                new SqlParameter("@Work",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Income",     SqlDbType.Decimal,    9),
                new SqlParameter("@Integral",   SqlDbType.Int,        4),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@LaseLogin",  SqlDbType.DateTime)
            };
            parameters[0].Value  = model.UserName;
            parameters[1].Value  = model.PassWord;
            parameters[2].Value  = model.Email;
            parameters[3].Value  = model.Name;
            parameters[4].Value  = model.Sex;
            parameters[5].Value  = model.Age;
            parameters[6].Value  = model.ID_Card;
            parameters[7].Value  = model.Phone;
            parameters[8].Value  = model.MobilPhone;
            parameters[9].Value  = model.Address;
            parameters[10].Value = model.Postalcode;
            parameters[11].Value = model.Work;
            parameters[12].Value = model.Income;
            parameters[13].Value = model.Integral;
            parameters[14].Value = model.CreateTime;
            parameters[15].Value = model.LaseLogin;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #2
0
파일: Show.aspx.cs 프로젝트: screwcat/pipe
 private void ShowInfo(int UserId)
 {
     ZhangWei.BLL.EUser   bll   = new ZhangWei.BLL.EUser();
     ZhangWei.Model.EUser model = bll.GetModel(UserId);
     this.lblUserId.Text     = model.UserId.ToString();
     this.lblUserName.Text   = model.UserName;
     this.lblPassWord.Text   = model.PassWord;
     this.lblEmail.Text      = model.Email;
     this.lblName.Text       = model.Name;
     this.lblSex.Text        = model.Sex;
     this.lblAge.Text        = model.Age.ToString();
     this.lblID_Card.Text    = model.ID_Card;
     this.lblPhone.Text      = model.Phone;
     this.lblMobilPhone.Text = model.MobilPhone;
     this.lblAddress.Text    = model.Address;
     this.lblPostalcode.Text = model.Postalcode;
     this.lblWork.Text       = model.Work;
     this.lblIncome.Text     = model.Income.ToString();
     this.lblIntegral.Text   = model.Integral.ToString();
     this.lblCreateTime.Text = model.CreateTime.ToString();
     this.lblLaseLogin.Text  = model.LaseLogin.ToString();
 }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体,从用户名
        /// </summary>
        public ZhangWei.Model.EUser GetModelByUN(string UserName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 UserId,UserName,PassWord,Email,Name,Sex,Age,ID_Card,Phone,MobilPhone,Address,Postalcode,Work,Income,Integral,CreateTime,LaseLogin from EUser ");
            strSql.Append(" where UserName=@UserName");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = UserName;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["UserId"] != null && ds.Tables[0].Rows[0]["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserName"] != null && ds.Tables[0].Rows[0]["UserName"].ToString() != "")
                {
                    model.UserName = ds.Tables[0].Rows[0]["UserName"].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]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Sex"] != null && ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Age"] != null && ds.Tables[0].Rows[0]["Age"].ToString() != "")
                {
                    model.Age = int.Parse(ds.Tables[0].Rows[0]["Age"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ID_Card"] != null && ds.Tables[0].Rows[0]["ID_Card"].ToString() != "")
                {
                    model.ID_Card = ds.Tables[0].Rows[0]["ID_Card"].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]["MobilPhone"] != null && ds.Tables[0].Rows[0]["MobilPhone"].ToString() != "")
                {
                    model.MobilPhone = ds.Tables[0].Rows[0]["MobilPhone"].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]["Postalcode"] != null && ds.Tables[0].Rows[0]["Postalcode"].ToString() != "")
                {
                    model.Postalcode = ds.Tables[0].Rows[0]["Postalcode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Work"] != null && ds.Tables[0].Rows[0]["Work"].ToString() != "")
                {
                    model.Work = ds.Tables[0].Rows[0]["Work"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Income"] != null && ds.Tables[0].Rows[0]["Income"].ToString() != "")
                {
                    model.Income = decimal.Parse(ds.Tables[0].Rows[0]["Income"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Integral"] != null && ds.Tables[0].Rows[0]["Integral"].ToString() != "")
                {
                    model.Integral = int.Parse(ds.Tables[0].Rows[0]["Integral"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LaseLogin"] != null && ds.Tables[0].Rows[0]["LaseLogin"].ToString() != "")
                {
                    model.LaseLogin = DateTime.Parse(ds.Tables[0].Rows[0]["LaseLogin"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.EUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update EUser set ");
            strSql.Append("UserName=@UserName,");
            strSql.Append("PassWord=@PassWord,");
            strSql.Append("Email=@Email,");
            strSql.Append("Name=@Name,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("Age=@Age,");
            strSql.Append("ID_Card=@ID_Card,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("MobilPhone=@MobilPhone,");
            strSql.Append("Address=@Address,");
            strSql.Append("Postalcode=@Postalcode,");
            strSql.Append("Work=@Work,");
            strSql.Append("Income=@Income,");
            strSql.Append("Integral=@Integral,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("LaseLogin=@LaseLogin");
            strSql.Append(" where UserId=@UserId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@PassWord",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Email",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Name",       SqlDbType.NVarChar,  20),
                new SqlParameter("@Sex",        SqlDbType.Char,       4),
                new SqlParameter("@Age",        SqlDbType.Int,        4),
                new SqlParameter("@ID_Card",    SqlDbType.NVarChar,  18),
                new SqlParameter("@Phone",      SqlDbType.NVarChar,  30),
                new SqlParameter("@MobilPhone", SqlDbType.NVarChar,  30),
                new SqlParameter("@Address",    SqlDbType.NVarChar),
                new SqlParameter("@Postalcode", SqlDbType.NVarChar,  10),
                new SqlParameter("@Work",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Income",     SqlDbType.Decimal,    9),
                new SqlParameter("@Integral",   SqlDbType.Int,        4),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@LaseLogin",  SqlDbType.DateTime),
                new SqlParameter("@UserId",     SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserName;
            parameters[1].Value  = model.PassWord;
            parameters[2].Value  = model.Email;
            parameters[3].Value  = model.Name;
            parameters[4].Value  = model.Sex;
            parameters[5].Value  = model.Age;
            parameters[6].Value  = model.ID_Card;
            parameters[7].Value  = model.Phone;
            parameters[8].Value  = model.MobilPhone;
            parameters[9].Value  = model.Address;
            parameters[10].Value = model.Postalcode;
            parameters[11].Value = model.Work;
            parameters[12].Value = model.Income;
            parameters[13].Value = model.Integral;
            parameters[14].Value = model.CreateTime;
            parameters[15].Value = model.LaseLogin;
            parameters[16].Value = model.UserId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtUserName.Text.Trim().Length == 0)
            {
                strErr += "UserName不能为空!\\n";
            }
            if (this.txtPassWord.Text.Trim().Length == 0)
            {
                strErr += "PassWord不能为空!\\n";
            }
            if (this.txtEmail.Text.Trim().Length == 0)
            {
                strErr += "Email不能为空!\\n";
            }
            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\n";
            }
            if (this.txtSex.Text.Trim().Length == 0)
            {
                strErr += "Sex不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtAge.Text))
            {
                strErr += "Age格式错误!\\n";
            }
            if (this.txtID_Card.Text.Trim().Length == 0)
            {
                strErr += "ID_Card不能为空!\\n";
            }
            if (this.txtPhone.Text.Trim().Length == 0)
            {
                strErr += "Phone不能为空!\\n";
            }
            if (this.txtMobilPhone.Text.Trim().Length == 0)
            {
                strErr += "MobilPhone不能为空!\\n";
            }
            if (this.txtAddress.Text.Trim().Length == 0)
            {
                strErr += "Address不能为空!\\n";
            }
            if (this.txtPostalcode.Text.Trim().Length == 0)
            {
                strErr += "Postalcode不能为空!\\n";
            }
            if (this.txtWork.Text.Trim().Length == 0)
            {
                strErr += "Work不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtIncome.Text))
            {
                strErr += "Income格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtIntegral.Text))
            {
                strErr += "Integral格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr += "CreateTime格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtLaseLogin.Text))
            {
                strErr += "LaseLogin格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      UserId     = int.Parse(this.lblUserId.Text);
            string   UserName   = this.txtUserName.Text;
            string   PassWord   = this.txtPassWord.Text;
            string   Email      = this.txtEmail.Text;
            string   Name       = this.txtName.Text;
            string   Sex        = this.txtSex.Text;
            int      Age        = int.Parse(this.txtAge.Text);
            string   ID_Card    = this.txtID_Card.Text;
            string   Phone      = this.txtPhone.Text;
            string   MobilPhone = this.txtMobilPhone.Text;
            string   Address    = this.txtAddress.Text;
            string   Postalcode = this.txtPostalcode.Text;
            string   Work       = this.txtWork.Text;
            decimal  Income     = decimal.Parse(this.txtIncome.Text);
            int      Integral   = int.Parse(this.txtIntegral.Text);
            DateTime CreateTime = DateTime.Parse(this.txtCreateTime.Text);
            DateTime LaseLogin  = DateTime.Parse(this.txtLaseLogin.Text);


            ZhangWei.Model.EUser model = new ZhangWei.Model.EUser();
            model.UserId     = UserId;
            model.UserName   = UserName;
            model.PassWord   = PassWord;
            model.Email      = Email;
            model.Name       = Name;
            model.Sex        = Sex;
            model.Age        = Age;
            model.ID_Card    = ID_Card;
            model.Phone      = Phone;
            model.MobilPhone = MobilPhone;
            model.Address    = Address;
            model.Postalcode = Postalcode;
            model.Work       = Work;
            model.Income     = Income;
            model.Integral   = Integral;
            model.CreateTime = CreateTime;
            model.LaseLogin  = LaseLogin;

            ZhangWei.BLL.EUser bll = new ZhangWei.BLL.EUser();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }