示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.geli.usermana model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update usermana set ");
            strSql.Append("username=@username,");
            strSql.Append("addtime=@addtime,");
            strSql.Append("password=@password,");
            strSql.Append("power=@power");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username", MySqlDbType.VarChar,   64),
                new MySqlParameter("@addtime",  MySqlDbType.DateTime),
                new MySqlParameter("@password", MySqlDbType.VarChar,   64),
                new MySqlParameter("@power",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@ID",       MySqlDbType.Int32, 64)
            };
            parameters[0].Value = model.username;
            parameters[1].Value = model.addtime;
            parameters[2].Value = model.password;
            parameters[3].Value = model.power;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.geli.usermana model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into usermana(");
            strSql.Append("username,addtime,password,power)");
            strSql.Append(" values (");
            strSql.Append("@username,@addtime,@password,@power)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@username", MySqlDbType.VarChar,   64),
                new MySqlParameter("@addtime",  MySqlDbType.DateTime),
                new MySqlParameter("@password", MySqlDbType.VarChar,   64),
                new MySqlParameter("@power",    MySqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.username;
            parameters[1].Value = model.addtime;
            parameters[2].Value = model.password;
            parameters[3].Value = model.power;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.geli.usermana DataRowToModel(DataRow row)
 {
     Maticsoft.Model.geli.usermana model = new Maticsoft.Model.geli.usermana();
     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["addtime"] != null && row["addtime"].ToString() != "")
         {
             model.addtime = DateTime.Parse(row["addtime"].ToString());
         }
         if (row["password"] != null)
         {
             model.password = row["password"].ToString();
         }
         if (row["power"] != null)
         {
             model.power = row["power"].ToString();
         }
     }
     return(model);
 }
示例#4
0
 private void ShowInfo(int ID)
 {
     Maticsoft.BLL.geli.usermana   bll   = new Maticsoft.BLL.geli.usermana();
     Maticsoft.Model.geli.usermana model = bll.GetModel(ID);
     this.lblID.Text       = model.ID.ToString();
     this.lblusername.Text = model.username;
     this.lbladdtime.Text  = model.addtime.ToString();
     this.lblpassword.Text = model.password;
     this.lblpower.Text    = model.power;
 }
示例#5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtusername.Text.Trim().Length == 0)
            {
                strErr += "username不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtaddtime.Text))
            {
                strErr += "addtime格式错误!\\n";
            }
            if (this.txtpassword.Text.Trim().Length == 0)
            {
                strErr += "password不能为空!\\n";
            }
            if (this.txtpower.Text.Trim().Length == 0)
            {
                strErr += "power不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID       = int.Parse(this.lblID.Text);
            string   username = this.txtusername.Text;
            DateTime addtime  = DateTime.Parse(this.txtaddtime.Text);
            string   password = this.txtpassword.Text;
            string   power    = this.txtpower.Text;


            Maticsoft.Model.geli.usermana model = new Maticsoft.Model.geli.usermana();
            model.ID       = ID;
            model.username = username;
            model.addtime  = addtime;
            model.password = password;
            model.power    = power;

            Maticsoft.BLL.geli.usermana bll = new Maticsoft.BLL.geli.usermana();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
示例#6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.geli.usermana GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,username,addtime,password,power from usermana ");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32)
            };
            parameters[0].Value = ID;

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

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