예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.cccc.cpinxinxi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update cpinxinxi set ");
            strSql.Append("cpbianh=@cpbianh,");
            strSql.Append("cgmc=@cgmc,");
            strSql.Append("xsmc=@xsmc");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@cpbianh", MySqlDbType.Int32,   64),
                new MySqlParameter("@cgmc",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@xsmc",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@id",      MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.cpbianh;
            parameters[1].Value = model.cgmc;
            parameters[2].Value = model.xsmc;
            parameters[3].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.cccc.cpinxinxi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into cpinxinxi(");
            strSql.Append("cpbianh,cgmc,xsmc)");
            strSql.Append(" values (");
            strSql.Append("@cpbianh,@cgmc,@xsmc)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@cpbianh", MySqlDbType.Int32,   64),
                new MySqlParameter("@cgmc",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@xsmc",    MySqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.cpbianh;
            parameters[1].Value = model.cgmc;
            parameters[2].Value = model.xsmc;

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

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

            if (!PageValidate.IsNumber(txtcpbianh.Text))
            {
                strErr += "cpbianh格式错误!\\n";
            }
            if (this.txtcgmc.Text.Trim().Length == 0)
            {
                strErr += "cgmc不能为空!\\n";
            }
            if (this.txtxsmc.Text.Trim().Length == 0)
            {
                strErr += "xsmc不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    cpbianh = int.Parse(this.txtcpbianh.Text);
            string cgmc    = this.txtcgmc.Text;
            string xsmc    = this.txtxsmc.Text;

            Maticsoft.Model.cccc.cpinxinxi model = new Maticsoft.Model.cccc.cpinxinxi();
            model.cpbianh = cpbianh;
            model.cgmc    = cgmc;
            model.xsmc    = xsmc;

            Maticsoft.BLL.cccc.cpinxinxi bll = new Maticsoft.BLL.cccc.cpinxinxi();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
예제 #4
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.cccc.cpinxinxi   bll   = new Maticsoft.BLL.cccc.cpinxinxi();
     Maticsoft.Model.cccc.cpinxinxi model = bll.GetModel(id);
     this.lblid.Text      = model.id.ToString();
     this.lblcpbianh.Text = model.cpbianh.ToString();
     this.lblcgmc.Text    = model.cgmc;
     this.lblxsmc.Text    = model.xsmc;
 }
예제 #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.cccc.cpinxinxi DataRowToModel(DataRow row)
 {
     Maticsoft.Model.cccc.cpinxinxi model = new Maticsoft.Model.cccc.cpinxinxi();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["cpbianh"] != null && row["cpbianh"].ToString() != "")
         {
             model.cpbianh = int.Parse(row["cpbianh"].ToString());
         }
         if (row["cgmc"] != null)
         {
             model.cgmc = row["cgmc"].ToString();
         }
         if (row["xsmc"] != null)
         {
             model.xsmc = row["xsmc"].ToString();
         }
     }
     return(model);
 }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.cccc.cpinxinxi GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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