private void ShowInfo() { Maticsoft.BLL.cccc.cg bll = new Maticsoft.BLL.cccc.cg(); Maticsoft.Model.cccc.cg model = bll.GetModel(); this.txtXUHAO.Text = model.XUHAO; this.txtRIQI.Text = model.RIQI; this.txtMINGCHEN.Text = model.MINGCHEN; this.txtCHESHU.Text = model.CHESHU; this.txtDUNWEI.Text = model.DUNWEI; this.txtDANJIA.Text = model.DANJIA; this.txtJINE.Text = model.JINE; this.txtBEIZHU.Text = model.BEIZHU; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.cccc.cg model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update cg set "); strSql.Append("XUHAO=@XUHAO,"); strSql.Append("RIQI=@RIQI,"); strSql.Append("MINGCHEN=@MINGCHEN,"); strSql.Append("CHESHU=@CHESHU,"); strSql.Append("DUNWEI=@DUNWEI,"); strSql.Append("DANJIA=@DANJIA,"); strSql.Append("JINE=@JINE,"); strSql.Append("BEIZHU=@BEIZHU"); strSql.Append(" where "); MySqlParameter[] parameters = { new MySqlParameter("@XUHAO", MySqlDbType.VarChar, 255), new MySqlParameter("@RIQI", MySqlDbType.VarChar, 255), new MySqlParameter("@MINGCHEN", MySqlDbType.VarChar, 255), new MySqlParameter("@CHESHU", MySqlDbType.VarChar, 255), new MySqlParameter("@DUNWEI", MySqlDbType.VarChar, 255), new MySqlParameter("@DANJIA", MySqlDbType.VarChar, 255), new MySqlParameter("@JINE", MySqlDbType.VarChar, 255), new MySqlParameter("@BEIZHU", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.XUHAO; parameters[1].Value = model.RIQI; parameters[2].Value = model.MINGCHEN; parameters[3].Value = model.CHESHU; parameters[4].Value = model.DUNWEI; parameters[5].Value = model.DANJIA; parameters[6].Value = model.JINE; parameters[7].Value = model.BEIZHU; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.cccc.cg DataRowToModel(DataRow row) { Maticsoft.Model.cccc.cg model = new Maticsoft.Model.cccc.cg(); if (row != null) { if (row["XUHAO"] != null) { model.XUHAO = row["XUHAO"].ToString(); } if (row["RIQI"] != null) { model.RIQI = row["RIQI"].ToString(); } if (row["MINGCHEN"] != null) { model.MINGCHEN = row["MINGCHEN"].ToString(); } if (row["CHESHU"] != null) { model.CHESHU = row["CHESHU"].ToString(); } if (row["DUNWEI"] != null) { model.DUNWEI = row["DUNWEI"].ToString(); } if (row["DANJIA"] != null) { model.DANJIA = row["DANJIA"].ToString(); } if (row["JINE"] != null) { model.JINE = row["JINE"].ToString(); } if (row["BEIZHU"] != null) { model.BEIZHU = row["BEIZHU"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.cccc.cg model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into cg("); strSql.Append("XUHAO,RIQI,MINGCHEN,CHESHU,DUNWEI,DANJIA,JINE,BEIZHU)"); strSql.Append(" values ("); strSql.Append("@XUHAO,@RIQI,@MINGCHEN,@CHESHU,@DUNWEI,@DANJIA,@JINE,@BEIZHU)"); MySqlParameter[] parameters = { new MySqlParameter("@XUHAO", MySqlDbType.VarChar, 255), new MySqlParameter("@RIQI", MySqlDbType.VarChar, 255), new MySqlParameter("@MINGCHEN", MySqlDbType.VarChar, 255), new MySqlParameter("@CHESHU", MySqlDbType.VarChar, 255), new MySqlParameter("@DUNWEI", MySqlDbType.VarChar, 255), new MySqlParameter("@DANJIA", MySqlDbType.VarChar, 255), new MySqlParameter("@JINE", MySqlDbType.VarChar, 255), new MySqlParameter("@BEIZHU", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.XUHAO; parameters[1].Value = model.RIQI; parameters[2].Value = model.MINGCHEN; parameters[3].Value = model.CHESHU; parameters[4].Value = model.DUNWEI; parameters[5].Value = model.DANJIA; parameters[6].Value = model.JINE; parameters[7].Value = model.BEIZHU; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.cccc.cg GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select XUHAO,RIQI,MINGCHEN,CHESHU,DUNWEI,DANJIA,JINE,BEIZHU from cg "); strSql.Append(" where "); MySqlParameter[] parameters = { }; Maticsoft.Model.cccc.cg model = new Maticsoft.Model.cccc.cg(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtXUHAO.Text.Trim().Length == 0) { strErr += "XUHAO不能为空!\\n"; } if (this.txtRIQI.Text.Trim().Length == 0) { strErr += "RIQI不能为空!\\n"; } if (this.txtMINGCHEN.Text.Trim().Length == 0) { strErr += "MINGCHEN不能为空!\\n"; } if (this.txtCHESHU.Text.Trim().Length == 0) { strErr += "CHESHU不能为空!\\n"; } if (this.txtDUNWEI.Text.Trim().Length == 0) { strErr += "DUNWEI不能为空!\\n"; } if (this.txtDANJIA.Text.Trim().Length == 0) { strErr += "DANJIA不能为空!\\n"; } if (this.txtJINE.Text.Trim().Length == 0) { strErr += "JINE不能为空!\\n"; } if (this.txtBEIZHU.Text.Trim().Length == 0) { strErr += "BEIZHU不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string XUHAO = this.txtXUHAO.Text; string RIQI = this.txtRIQI.Text; string MINGCHEN = this.txtMINGCHEN.Text; string CHESHU = this.txtCHESHU.Text; string DUNWEI = this.txtDUNWEI.Text; string DANJIA = this.txtDANJIA.Text; string JINE = this.txtJINE.Text; string BEIZHU = this.txtBEIZHU.Text; Maticsoft.Model.cccc.cg model = new Maticsoft.Model.cccc.cg(); model.XUHAO = XUHAO; model.RIQI = RIQI; model.MINGCHEN = MINGCHEN; model.CHESHU = CHESHU; model.DUNWEI = DUNWEI; model.DANJIA = DANJIA; model.JINE = JINE; model.BEIZHU = BEIZHU; Maticsoft.BLL.cccc.cg bll = new Maticsoft.BLL.cccc.cg(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }