Example #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtdanwei.Text.Trim().Length == 0)
            {
                strErr += "danwei不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    id     = int.Parse(this.lblid.Text);
            string danwei = this.txtdanwei.Text;


            Maticsoft.Model.cccc.danweixinxi model = new Maticsoft.Model.cccc.danweixinxi();
            model.id     = id;
            model.danwei = danwei;

            Maticsoft.BLL.cccc.danweixinxi bll = new Maticsoft.BLL.cccc.danweixinxi();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #2
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.cccc.danweixinxi   bll   = new Maticsoft.BLL.cccc.danweixinxi();
     Maticsoft.Model.cccc.danweixinxi model = bll.GetModel(id);
     this.lblid.Text     = model.id.ToString();
     this.txtdanwei.Text = model.danwei;
 }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.cccc.danweixinxi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update danweixinxi set ");
            strSql.Append("danwei=@danwei");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@danwei", MySqlDbType.VarChar, 64),
                new MySqlParameter("@id",     MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.danwei;
            parameters[1].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.cccc.danweixinxi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into danweixinxi(");
            strSql.Append("danwei)");
            strSql.Append(" values (");
            strSql.Append("@danwei)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@danwei", MySqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.danwei;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.cccc.danweixinxi DataRowToModel(DataRow row)
 {
     Maticsoft.Model.cccc.danweixinxi model = new Maticsoft.Model.cccc.danweixinxi();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["danwei"] != null)
         {
             model.danwei = row["danwei"].ToString();
         }
     }
     return(model);
 }
Example #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtdanwei.Text.Trim().Length == 0)
            {
                strErr += "danwei不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string danwei = this.txtdanwei.Text;

            Maticsoft.Model.cccc.danweixinxi model = new Maticsoft.Model.cccc.danweixinxi();
            model.danwei = danwei;

            Maticsoft.BLL.cccc.danweixinxi bll = new Maticsoft.BLL.cccc.danweixinxi();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Example #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.cccc.danweixinxi GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,danwei from danweixinxi ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

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

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