/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.cccc.xx_fapiao model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into xx_fapiao("); strSql.Append("xsdbhao,kpren,fpnxing,jbanr,lxr,fph,riqi,kpdanw,kpdunwei,kpjine,shuinv,shuie,bz)"); strSql.Append(" values ("); strSql.Append("@xsdbhao,@kpren,@fpnxing,@jbanr,@lxr,@fph,@riqi,@kpdanw,@kpdunwei,@kpjine,@shuinv,@shuie,@bz)"); MySqlParameter[] parameters = { new MySqlParameter("@xsdbhao", MySqlDbType.VarChar, 64), new MySqlParameter("@kpren", MySqlDbType.VarChar, 64), new MySqlParameter("@fpnxing", MySqlDbType.VarChar, 64), new MySqlParameter("@jbanr", MySqlDbType.VarChar, 64), new MySqlParameter("@lxr", MySqlDbType.Int32, 64), new MySqlParameter("@fph", MySqlDbType.Int32, 64), new MySqlParameter("@riqi", MySqlDbType.DateTime), new MySqlParameter("@kpdanw", MySqlDbType.VarChar, 64), new MySqlParameter("@kpdunwei", MySqlDbType.Int32, 64), new MySqlParameter("@kpjine", MySqlDbType.Int32, 64), new MySqlParameter("@shuinv", MySqlDbType.VarChar, 64), new MySqlParameter("@shuie", MySqlDbType.Int32, 64), new MySqlParameter("@bz", MySqlDbType.VarChar, 64) }; parameters[0].Value = model.xsdbhao; parameters[1].Value = model.kpren; parameters[2].Value = model.fpnxing; parameters[3].Value = model.jbanr; parameters[4].Value = model.lxr; parameters[5].Value = model.fph; parameters[6].Value = model.riqi; parameters[7].Value = model.kpdanw; parameters[8].Value = model.kpdunwei; parameters[9].Value = model.kpjine; parameters[10].Value = model.shuinv; parameters[11].Value = model.shuie; parameters[12].Value = model.bz; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(int id) { Maticsoft.BLL.cccc.xx_fapiao bll = new Maticsoft.BLL.cccc.xx_fapiao(); Maticsoft.Model.cccc.xx_fapiao model = bll.GetModel(id); this.lblid.Text = model.id.ToString(); this.lblxsdbhao.Text = model.xsdbhao; this.lblkpren.Text = model.kpren; this.lblfpnxing.Text = model.fpnxing; this.lbljbanr.Text = model.jbanr; this.lbllxr.Text = model.lxr.ToString(); this.lblfph.Text = model.fph.ToString(); this.lblriqi.Text = model.riqi.ToString(); this.lblkpdanw.Text = model.kpdanw; this.lblkpdunwei.Text = model.kpdunwei.ToString(); this.lblkpjine.Text = model.kpjine.ToString(); this.lblshuinv.Text = model.shuinv; this.lblshuie.Text = model.shuie.ToString(); this.lblbz.Text = model.bz; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.cccc.xx_fapiao GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,xsdbhao,kpren,fpnxing,jbanr,lxr,fph,riqi,kpdanw,kpdunwei,kpjine,shuinv,shuie,bz from xx_fapiao "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; Maticsoft.Model.cccc.xx_fapiao model = new Maticsoft.Model.cccc.xx_fapiao(); 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.txtxsdbhao.Text.Trim().Length == 0) { strErr += "xsdbhao不能为空!\\n"; } if (this.txtkpren.Text.Trim().Length == 0) { strErr += "kpren不能为空!\\n"; } if (this.txtfpnxing.Text.Trim().Length == 0) { strErr += "fpnxing不能为空!\\n"; } if (this.txtjbanr.Text.Trim().Length == 0) { strErr += "jbanr不能为空!\\n"; } if (!PageValidate.IsNumber(txtlxr.Text)) { strErr += "lxr格式错误!\\n"; } if (!PageValidate.IsNumber(txtfph.Text)) { strErr += "fph格式错误!\\n"; } if (!PageValidate.IsDateTime(txtriqi.Text)) { strErr += "riqi格式错误!\\n"; } if (this.txtkpdanw.Text.Trim().Length == 0) { strErr += "kpdanw不能为空!\\n"; } if (!PageValidate.IsNumber(txtkpdunwei.Text)) { strErr += "kpdunwei格式错误!\\n"; } if (!PageValidate.IsNumber(txtkpjine.Text)) { strErr += "kpjine格式错误!\\n"; } if (this.txtshuinv.Text.Trim().Length == 0) { strErr += "shuinv不能为空!\\n"; } if (!PageValidate.IsNumber(txtshuie.Text)) { strErr += "shuie格式错误!\\n"; } if (this.txtbz.Text.Trim().Length == 0) { strErr += "bz不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int id = int.Parse(this.lblid.Text); string xsdbhao = this.txtxsdbhao.Text; string kpren = this.txtkpren.Text; string fpnxing = this.txtfpnxing.Text; string jbanr = this.txtjbanr.Text; int lxr = int.Parse(this.txtlxr.Text); int fph = int.Parse(this.txtfph.Text); DateTime riqi = DateTime.Parse(this.txtriqi.Text); string kpdanw = this.txtkpdanw.Text; int kpdunwei = int.Parse(this.txtkpdunwei.Text); int kpjine = int.Parse(this.txtkpjine.Text); string shuinv = this.txtshuinv.Text; int shuie = int.Parse(this.txtshuie.Text); string bz = this.txtbz.Text; Maticsoft.Model.cccc.xx_fapiao model = new Maticsoft.Model.cccc.xx_fapiao(); model.id = id; model.xsdbhao = xsdbhao; model.kpren = kpren; model.fpnxing = fpnxing; model.jbanr = jbanr; model.lxr = lxr; model.fph = fph; model.riqi = riqi; model.kpdanw = kpdanw; model.kpdunwei = kpdunwei; model.kpjine = kpjine; model.shuinv = shuinv; model.shuie = shuie; model.bz = bz; Maticsoft.BLL.cccc.xx_fapiao bll = new Maticsoft.BLL.cccc.xx_fapiao(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.cccc.xx_fapiao DataRowToModel(DataRow row) { Maticsoft.Model.cccc.xx_fapiao model = new Maticsoft.Model.cccc.xx_fapiao(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["xsdbhao"] != null) { model.xsdbhao = row["xsdbhao"].ToString(); } if (row["kpren"] != null) { model.kpren = row["kpren"].ToString(); } if (row["fpnxing"] != null) { model.fpnxing = row["fpnxing"].ToString(); } if (row["jbanr"] != null) { model.jbanr = row["jbanr"].ToString(); } if (row["lxr"] != null && row["lxr"].ToString() != "") { model.lxr = int.Parse(row["lxr"].ToString()); } if (row["fph"] != null && row["fph"].ToString() != "") { model.fph = int.Parse(row["fph"].ToString()); } if (row["riqi"] != null && row["riqi"].ToString() != "") { model.riqi = DateTime.Parse(row["riqi"].ToString()); } if (row["kpdanw"] != null) { model.kpdanw = row["kpdanw"].ToString(); } if (row["kpdunwei"] != null && row["kpdunwei"].ToString() != "") { model.kpdunwei = int.Parse(row["kpdunwei"].ToString()); } if (row["kpjine"] != null && row["kpjine"].ToString() != "") { model.kpjine = int.Parse(row["kpjine"].ToString()); } if (row["shuinv"] != null) { model.shuinv = row["shuinv"].ToString(); } if (row["shuie"] != null && row["shuie"].ToString() != "") { model.shuie = int.Parse(row["shuie"].ToString()); } if (row["bz"] != null) { model.bz = row["bz"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.cccc.xx_fapiao model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update xx_fapiao set "); strSql.Append("xsdbhao=@xsdbhao,"); strSql.Append("kpren=@kpren,"); strSql.Append("fpnxing=@fpnxing,"); strSql.Append("jbanr=@jbanr,"); strSql.Append("lxr=@lxr,"); strSql.Append("fph=@fph,"); strSql.Append("riqi=@riqi,"); strSql.Append("kpdanw=@kpdanw,"); strSql.Append("kpdunwei=@kpdunwei,"); strSql.Append("kpjine=@kpjine,"); strSql.Append("shuinv=@shuinv,"); strSql.Append("shuie=@shuie,"); strSql.Append("bz=@bz"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@xsdbhao", MySqlDbType.VarChar, 64), new MySqlParameter("@kpren", MySqlDbType.VarChar, 64), new MySqlParameter("@fpnxing", MySqlDbType.VarChar, 64), new MySqlParameter("@jbanr", MySqlDbType.VarChar, 64), new MySqlParameter("@lxr", MySqlDbType.Int32, 64), new MySqlParameter("@fph", MySqlDbType.Int32, 64), new MySqlParameter("@riqi", MySqlDbType.DateTime), new MySqlParameter("@kpdanw", MySqlDbType.VarChar, 64), new MySqlParameter("@kpdunwei", MySqlDbType.Int32, 64), new MySqlParameter("@kpjine", MySqlDbType.Int32, 64), new MySqlParameter("@shuinv", MySqlDbType.VarChar, 64), new MySqlParameter("@shuie", MySqlDbType.Int32, 64), new MySqlParameter("@bz", MySqlDbType.VarChar, 64), new MySqlParameter("@id", MySqlDbType.Int32, 64) }; parameters[0].Value = model.xsdbhao; parameters[1].Value = model.kpren; parameters[2].Value = model.fpnxing; parameters[3].Value = model.jbanr; parameters[4].Value = model.lxr; parameters[5].Value = model.fph; parameters[6].Value = model.riqi; parameters[7].Value = model.kpdanw; parameters[8].Value = model.kpdunwei; parameters[9].Value = model.kpjine; parameters[10].Value = model.shuinv; parameters[11].Value = model.shuie; parameters[12].Value = model.bz; parameters[13].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }