示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tuser(");
            strSql.Append("userId,username,password,address)");
            strSql.Append(" values (");
            strSql.Append("@userId,@username,@password,@address)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@userId",   MySqlDbType.Int32,     4),
                new MySqlParameter("@username", MySqlDbType.VarChar, 100),
                new MySqlParameter("@password", MySqlDbType.VarChar, 100),
                new MySqlParameter("@address",  MySqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.userId;
            parameters[1].Value = model.username;
            parameters[2].Value = model.password;
            parameters[3].Value = model.address;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tuser set ");
            strSql.Append("username=@username,");
            strSql.Append("password=@password,");
            strSql.Append("address=@address");
            strSql.Append(" where userId=@userId ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username", MySqlDbType.VarChar, 100),
                new MySqlParameter("@password", MySqlDbType.VarChar, 100),
                new MySqlParameter("@address",  MySqlDbType.VarChar, 100),
                new MySqlParameter("@userId",   MySqlDbType.Int32, 4)
            };
            parameters[0].Value = model.username;
            parameters[1].Value = model.password;
            parameters[2].Value = model.address;
            parameters[3].Value = model.userId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 private void ShowInfo(int userId)
 {
     Maticsoft.BLL.user   bll   = new Maticsoft.BLL.user();
     Maticsoft.Model.user model = bll.GetModel(userId);
     this.lbluserId.Text   = model.userId.ToString();
     this.lblusername.Text = model.username;
     this.lblpassword.Text = model.password;
     this.lbladdress.Text  = model.address;
 }
示例#4
0
文件: user.cs 项目: mRcfps/bdcloud
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into user(");
            strSql.Append("username,password,createdTime,lastLoginTime,privilege,remark,sn,section,policeNO,cardNO,partment,telephone,phone,email,userrole,allParent,header)");
            strSql.Append(" values (");
            strSql.Append("@username,@password,@createdTime,@lastLoginTime,@privilege,@remark,@sn,@section,@policeNO,@cardNO,@partment,@telephone,@phone,@email,@userrole,@allParent,@header)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username",      MySqlDbType.VarChar, 100),
                new MySqlParameter("@password",      MySqlDbType.VarChar, 100),
                new MySqlParameter("@createdTime",   MySqlDbType.VarChar, 100),
                new MySqlParameter("@lastLoginTime", MySqlDbType.VarChar, 100),
                new MySqlParameter("@privilege",     MySqlDbType.VarChar, 100),
                new MySqlParameter("@remark",        MySqlDbType.VarChar, 500),
                new MySqlParameter("@sn",            MySqlDbType.VarChar, 100),
                new MySqlParameter("@section",       MySqlDbType.VarChar, 100),
                new MySqlParameter("@policeNO",      MySqlDbType.VarChar, 150),
                new MySqlParameter("@cardNO",        MySqlDbType.VarChar, 100),
                new MySqlParameter("@partment",      MySqlDbType.VarChar, 200),
                new MySqlParameter("@telephone",     MySqlDbType.VarChar,  50),
                new MySqlParameter("@phone",         MySqlDbType.VarChar,  50),
                new MySqlParameter("@email",         MySqlDbType.VarChar, 150),
                new MySqlParameter("@userrole",      MySqlDbType.VarChar, 111),
                new MySqlParameter("@allParent",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@header",        MySqlDbType.LongBlob)
            };
            parameters[0].Value  = model.username;
            parameters[1].Value  = model.password;
            parameters[2].Value  = model.createdTime;
            parameters[3].Value  = model.lastLoginTime;
            parameters[4].Value  = model.privilege;
            parameters[5].Value  = model.remark;
            parameters[6].Value  = model.sn;
            parameters[7].Value  = model.section;
            parameters[8].Value  = model.policeNO;
            parameters[9].Value  = model.cardNO;
            parameters[10].Value = model.partment;
            parameters[11].Value = model.telephone;
            parameters[12].Value = model.phone;
            parameters[13].Value = model.email;
            parameters[14].Value = model.userrole;
            parameters[15].Value = model.allParent;
            parameters[16].Value = model.header;

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

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

            if (!PageValidate.IsNumber(txtuserId.Text))
            {
                strErr += "userId格式错误!\\n";
            }
            if (this.txtusername.Text.Trim().Length == 0)
            {
                strErr += "username不能为空!\\n";
            }
            if (this.txtpassword.Text.Trim().Length == 0)
            {
                strErr += "password不能为空!\\n";
            }
            if (this.txtaddress.Text.Trim().Length == 0)
            {
                strErr += "address不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    userId   = int.Parse(this.txtuserId.Text);
            string username = this.txtusername.Text;
            string password = this.txtpassword.Text;
            string address  = this.txtaddress.Text;

            Maticsoft.Model.user model = new Maticsoft.Model.user();
            model.userId   = userId;
            model.username = username;
            model.password = password;
            model.address  = address;

            Maticsoft.BLL.user bll = new Maticsoft.BLL.user();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
示例#6
0
        private void confirmButton_Click(object sender, EventArgs e)
        {
            if (this.pickedImage != null)
            {
                // 将头像信息存储到UserInfo类中
                UserInfo.header = this.pickedImage;

                // 将头像图片存入数据库
                Maticsoft.DAL.user   userDAL   = new Maticsoft.DAL.user();
                Maticsoft.Model.user userModel = userDAL.GetModel(UserInfo.id);
                userModel.header = ImageToBytes(this.pickedImage);
                userDAL.Update(userModel);

                // 在主界面中更新头像
                Form1.form1.LoadHeader();

                this.Close();
            }
            else
            {
                MessageBox.Show("请先选择头像!");
            }
        }
示例#7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.user DataRowToModel(DataRow row)
 {
     Maticsoft.Model.user model = new Maticsoft.Model.user();
     if (row != null)
     {
         if (row["userId"] != null && row["userId"].ToString() != "")
         {
             model.userId = int.Parse(row["userId"].ToString());
         }
         if (row["username"] != null)
         {
             model.username = row["username"].ToString();
         }
         if (row["password"] != null)
         {
             model.password = row["password"].ToString();
         }
         if (row["address"] != null)
         {
             model.address = row["address"].ToString();
         }
     }
     return(model);
 }
示例#8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.user GetModel(int userId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select userId,username,password,address from tuser ");
            strSql.Append(" where userId=@userId ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@userId", MySqlDbType.Int32, 4)
            };
            parameters[0].Value = userId;

            Maticsoft.Model.user model = new Maticsoft.Model.user();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#9
0
文件: user.cs 项目: mRcfps/bdcloud
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.user GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,username,password,createdTime,lastLoginTime,privilege,remark,sn,section,policeNO,cardNO,partment,telephone,phone,email,userrole,allParent,header from user ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            Maticsoft.Model.user model = new Maticsoft.Model.user();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#10
0
文件: user.cs 项目: mRcfps/bdcloud
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.user DataRowToModel(DataRow row)
 {
     Maticsoft.Model.user model = new Maticsoft.Model.user();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["username"] != null)
         {
             model.username = row["username"].ToString();
         }
         if (row["password"] != null)
         {
             model.password = row["password"].ToString();
         }
         if (row["createdTime"] != null)
         {
             model.createdTime = row["createdTime"].ToString();
         }
         if (row["lastLoginTime"] != null)
         {
             model.lastLoginTime = row["lastLoginTime"].ToString();
         }
         if (row["privilege"] != null)
         {
             model.privilege = row["privilege"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["sn"] != null)
         {
             model.sn = row["sn"].ToString();
         }
         if (row["section"] != null)
         {
             model.section = row["section"].ToString();
         }
         if (row["policeNO"] != null)
         {
             model.policeNO = row["policeNO"].ToString();
         }
         if (row["cardNO"] != null)
         {
             model.cardNO = row["cardNO"].ToString();
         }
         if (row["partment"] != null)
         {
             model.partment = row["partment"].ToString();
         }
         if (row["telephone"] != null)
         {
             model.telephone = row["telephone"].ToString();
         }
         if (row["phone"] != null)
         {
             model.phone = row["phone"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["userrole"] != null)
         {
             model.userrole = row["userrole"].ToString();
         }
         if (row["allParent"] != null)
         {
             model.allParent = row["allParent"].ToString();
         }
         if (row["header"] != null)
         {
             model.header = row["header"] as byte[];
         }
     }
     return(model);
 }
示例#11
0
文件: user.cs 项目: mRcfps/bdcloud
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update user set ");
            strSql.Append("username=@username,");
            strSql.Append("password=@password,");
            strSql.Append("createdTime=@createdTime,");
            strSql.Append("lastLoginTime=@lastLoginTime,");
            strSql.Append("privilege=@privilege,");
            strSql.Append("remark=@remark,");
            strSql.Append("sn=@sn,");
            strSql.Append("section=@section,");
            strSql.Append("policeNO=@policeNO,");
            strSql.Append("cardNO=@cardNO,");
            strSql.Append("partment=@partment,");
            strSql.Append("telephone=@telephone,");
            strSql.Append("phone=@phone,");
            strSql.Append("email=@email,");
            strSql.Append("userrole=@userrole,");
            strSql.Append("allParent=@allParent,");
            strSql.Append("header=@header");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username",      MySqlDbType.VarChar,   100),
                new MySqlParameter("@password",      MySqlDbType.VarChar,   100),
                new MySqlParameter("@createdTime",   MySqlDbType.VarChar,   100),
                new MySqlParameter("@lastLoginTime", MySqlDbType.VarChar,   100),
                new MySqlParameter("@privilege",     MySqlDbType.VarChar,   100),
                new MySqlParameter("@remark",        MySqlDbType.VarChar,   500),
                new MySqlParameter("@sn",            MySqlDbType.VarChar,   100),
                new MySqlParameter("@section",       MySqlDbType.VarChar,   100),
                new MySqlParameter("@policeNO",      MySqlDbType.VarChar,   150),
                new MySqlParameter("@cardNO",        MySqlDbType.VarChar,   100),
                new MySqlParameter("@partment",      MySqlDbType.VarChar,   200),
                new MySqlParameter("@telephone",     MySqlDbType.VarChar,    50),
                new MySqlParameter("@phone",         MySqlDbType.VarChar,    50),
                new MySqlParameter("@email",         MySqlDbType.VarChar,   150),
                new MySqlParameter("@userrole",      MySqlDbType.VarChar,   111),
                new MySqlParameter("@allParent",     MySqlDbType.VarChar,   255),
                new MySqlParameter("@header",        MySqlDbType.LongBlob),
                new MySqlParameter("@id",            MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.username;
            parameters[1].Value  = model.password;
            parameters[2].Value  = model.createdTime;
            parameters[3].Value  = model.lastLoginTime;
            parameters[4].Value  = model.privilege;
            parameters[5].Value  = model.remark;
            parameters[6].Value  = model.sn;
            parameters[7].Value  = model.section;
            parameters[8].Value  = model.policeNO;
            parameters[9].Value  = model.cardNO;
            parameters[10].Value = model.partment;
            parameters[11].Value = model.telephone;
            parameters[12].Value = model.phone;
            parameters[13].Value = model.email;
            parameters[14].Value = model.userrole;
            parameters[15].Value = model.allParent;
            parameters[16].Value = model.header;
            parameters[17].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }