/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.cccc.nep model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into nep("); strSql.Append("cpmc,cs,ssdw,kfdw,dc,dj,je,bz,gydw,jsr,sj,ddbh,djbh,skfs,fkjine,yue)"); strSql.Append(" values ("); strSql.Append("@cpmc,@cs,@ssdw,@kfdw,@dc,@dj,@je,@bz,@gydw,@jsr,@sj,@ddbh,@djbh,@skfs,@fkjine,@yue)"); MySqlParameter[] parameters = { new MySqlParameter("@cpmc", MySqlDbType.VarChar, 64), new MySqlParameter("@cs", MySqlDbType.Int32, 64), new MySqlParameter("@ssdw", MySqlDbType.Int32, 64), new MySqlParameter("@kfdw", MySqlDbType.Int32, 64), new MySqlParameter("@dc", MySqlDbType.Int32, 64), new MySqlParameter("@dj", MySqlDbType.Int32, 64), new MySqlParameter("@je", MySqlDbType.Int32, 64), new MySqlParameter("@bz", MySqlDbType.VarChar, 64), new MySqlParameter("@gydw", MySqlDbType.VarChar, 64), new MySqlParameter("@jsr", MySqlDbType.VarChar, 64), new MySqlParameter("@sj", MySqlDbType.DateTime), new MySqlParameter("@ddbh", MySqlDbType.VarChar, 64), new MySqlParameter("@djbh", MySqlDbType.VarChar, 64), new MySqlParameter("@skfs", MySqlDbType.VarChar, 64), new MySqlParameter("@fkjine", MySqlDbType.Int32, 64), new MySqlParameter("@yue", MySqlDbType.Int32, 64) }; parameters[0].Value = model.cpmc; parameters[1].Value = model.cs; parameters[2].Value = model.ssdw; parameters[3].Value = model.kfdw; parameters[4].Value = model.dc; parameters[5].Value = model.dj; parameters[6].Value = model.je; parameters[7].Value = model.bz; parameters[8].Value = model.gydw; parameters[9].Value = model.jsr; parameters[10].Value = model.sj; parameters[11].Value = model.ddbh; parameters[12].Value = model.djbh; parameters[13].Value = model.skfs; parameters[14].Value = model.fkjine; parameters[15].Value = model.yue; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(int id) { Maticsoft.BLL.cccc.nep bll = new Maticsoft.BLL.cccc.nep(); Maticsoft.Model.cccc.nep model = bll.GetModel(id); this.lblid.Text = model.id.ToString(); this.txtcpmc.Text = model.cpmc; this.txtcs.Text = model.cs.ToString(); this.txtssdw.Text = model.ssdw.ToString(); this.txtkfdw.Text = model.kfdw.ToString(); this.txtdc.Text = model.dc.ToString(); this.txtdj.Text = model.dj.ToString(); this.txtje.Text = model.je.ToString(); this.txtbz.Text = model.bz; this.txtgydw.Text = model.gydw; this.txtjsr.Text = model.jsr; this.txtsj.Text = model.sj.ToString(); this.txtddbh.Text = model.ddbh; this.txtdjbh.Text = model.djbh; this.txtskfs.Text = model.skfs; this.txtfkjine.Text = model.fkjine.ToString(); this.txtyue.Text = model.yue.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.cccc.nep GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,cpmc,cs,ssdw,kfdw,dc,dj,je,bz,gydw,jsr,sj,ddbh,djbh,skfs,fkjine,yue from nep "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; Maticsoft.Model.cccc.nep model = new Maticsoft.Model.cccc.nep(); 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.txtcpmc.Text.Trim().Length == 0) { strErr += "cpmc不能为空!\\n"; } if (!PageValidate.IsNumber(txtcs.Text)) { strErr += "cs格式错误!\\n"; } if (!PageValidate.IsNumber(txtssdw.Text)) { strErr += "ssdw格式错误!\\n"; } if (!PageValidate.IsNumber(txtkfdw.Text)) { strErr += "kfdw格式错误!\\n"; } if (!PageValidate.IsNumber(txtdc.Text)) { strErr += "dc格式错误!\\n"; } if (!PageValidate.IsNumber(txtdj.Text)) { strErr += "dj格式错误!\\n"; } if (!PageValidate.IsNumber(txtje.Text)) { strErr += "je格式错误!\\n"; } if (this.txtbz.Text.Trim().Length == 0) { strErr += "bz不能为空!\\n"; } if (this.txtgydw.Text.Trim().Length == 0) { strErr += "gydw不能为空!\\n"; } if (this.txtjsr.Text.Trim().Length == 0) { strErr += "jsr不能为空!\\n"; } if (!PageValidate.IsDateTime(txtsj.Text)) { strErr += "sj格式错误!\\n"; } if (this.txtddbh.Text.Trim().Length == 0) { strErr += "ddbh不能为空!\\n"; } if (this.txtdjbh.Text.Trim().Length == 0) { strErr += "djbh不能为空!\\n"; } if (this.txtskfs.Text.Trim().Length == 0) { strErr += "skfs不能为空!\\n"; } if (!PageValidate.IsNumber(txtfkjine.Text)) { strErr += "fkjine格式错误!\\n"; } if (!PageValidate.IsNumber(txtyue.Text)) { strErr += "yue格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int id = int.Parse(this.lblid.Text); string cpmc = this.txtcpmc.Text; int cs = int.Parse(this.txtcs.Text); int ssdw = int.Parse(this.txtssdw.Text); int kfdw = int.Parse(this.txtkfdw.Text); int dc = int.Parse(this.txtdc.Text); int dj = int.Parse(this.txtdj.Text); int je = int.Parse(this.txtje.Text); string bz = this.txtbz.Text; string gydw = this.txtgydw.Text; string jsr = this.txtjsr.Text; DateTime sj = DateTime.Parse(this.txtsj.Text); string ddbh = this.txtddbh.Text; string djbh = this.txtdjbh.Text; string skfs = this.txtskfs.Text; int fkjine = int.Parse(this.txtfkjine.Text); int yue = int.Parse(this.txtyue.Text); Maticsoft.Model.cccc.nep model = new Maticsoft.Model.cccc.nep(); model.id = id; model.cpmc = cpmc; model.cs = cs; model.ssdw = ssdw; model.kfdw = kfdw; model.dc = dc; model.dj = dj; model.je = je; model.bz = bz; model.gydw = gydw; model.jsr = jsr; model.sj = sj; model.ddbh = ddbh; model.djbh = djbh; model.skfs = skfs; model.fkjine = fkjine; model.yue = yue; Maticsoft.BLL.cccc.nep bll = new Maticsoft.BLL.cccc.nep(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.cccc.nep DataRowToModel(DataRow row) { Maticsoft.Model.cccc.nep model = new Maticsoft.Model.cccc.nep(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["cpmc"] != null) { model.cpmc = row["cpmc"].ToString(); } if (row["cs"] != null && row["cs"].ToString() != "") { model.cs = int.Parse(row["cs"].ToString()); } if (row["ssdw"] != null && row["ssdw"].ToString() != "") { model.ssdw = int.Parse(row["ssdw"].ToString()); } if (row["kfdw"] != null && row["kfdw"].ToString() != "") { model.kfdw = int.Parse(row["kfdw"].ToString()); } if (row["dc"] != null && row["dc"].ToString() != "") { model.dc = int.Parse(row["dc"].ToString()); } if (row["dj"] != null && row["dj"].ToString() != "") { model.dj = int.Parse(row["dj"].ToString()); } if (row["je"] != null && row["je"].ToString() != "") { model.je = int.Parse(row["je"].ToString()); } if (row["bz"] != null) { model.bz = row["bz"].ToString(); } if (row["gydw"] != null) { model.gydw = row["gydw"].ToString(); } if (row["jsr"] != null) { model.jsr = row["jsr"].ToString(); } if (row["sj"] != null && row["sj"].ToString() != "") { model.sj = DateTime.Parse(row["sj"].ToString()); } if (row["ddbh"] != null) { model.ddbh = row["ddbh"].ToString(); } if (row["djbh"] != null) { model.djbh = row["djbh"].ToString(); } if (row["skfs"] != null) { model.skfs = row["skfs"].ToString(); } if (row["fkjine"] != null && row["fkjine"].ToString() != "") { model.fkjine = int.Parse(row["fkjine"].ToString()); } if (row["yue"] != null && row["yue"].ToString() != "") { model.yue = int.Parse(row["yue"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.cccc.nep model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update nep set "); strSql.Append("cpmc=@cpmc,"); strSql.Append("cs=@cs,"); strSql.Append("ssdw=@ssdw,"); strSql.Append("kfdw=@kfdw,"); strSql.Append("dc=@dc,"); strSql.Append("dj=@dj,"); strSql.Append("je=@je,"); strSql.Append("bz=@bz,"); strSql.Append("gydw=@gydw,"); strSql.Append("jsr=@jsr,"); strSql.Append("sj=@sj,"); strSql.Append("ddbh=@ddbh,"); strSql.Append("djbh=@djbh,"); strSql.Append("skfs=@skfs,"); strSql.Append("fkjine=@fkjine,"); strSql.Append("yue=@yue"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@cpmc", MySqlDbType.VarChar, 64), new MySqlParameter("@cs", MySqlDbType.Int32, 64), new MySqlParameter("@ssdw", MySqlDbType.Int32, 64), new MySqlParameter("@kfdw", MySqlDbType.Int32, 64), new MySqlParameter("@dc", MySqlDbType.Int32, 64), new MySqlParameter("@dj", MySqlDbType.Int32, 64), new MySqlParameter("@je", MySqlDbType.Int32, 64), new MySqlParameter("@bz", MySqlDbType.VarChar, 64), new MySqlParameter("@gydw", MySqlDbType.VarChar, 64), new MySqlParameter("@jsr", MySqlDbType.VarChar, 64), new MySqlParameter("@sj", MySqlDbType.DateTime), new MySqlParameter("@ddbh", MySqlDbType.VarChar, 64), new MySqlParameter("@djbh", MySqlDbType.VarChar, 64), new MySqlParameter("@skfs", MySqlDbType.VarChar, 64), new MySqlParameter("@fkjine", MySqlDbType.Int32, 64), new MySqlParameter("@yue", MySqlDbType.Int32, 64), new MySqlParameter("@id", MySqlDbType.Int32, 64) }; parameters[0].Value = model.cpmc; parameters[1].Value = model.cs; parameters[2].Value = model.ssdw; parameters[3].Value = model.kfdw; parameters[4].Value = model.dc; parameters[5].Value = model.dj; parameters[6].Value = model.je; parameters[7].Value = model.bz; parameters[8].Value = model.gydw; parameters[9].Value = model.jsr; parameters[10].Value = model.sj; parameters[11].Value = model.ddbh; parameters[12].Value = model.djbh; parameters[13].Value = model.skfs; parameters[14].Value = model.fkjine; parameters[15].Value = model.yue; parameters[16].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }