private void ShowInfo() { MyERP.BLL.PUB_BMTMP bll = new MyERP.BLL.PUB_BMTMP(); MyERP.Model.PUB_BMTMP model = bll.GetModel(); this.lblBMCODE.Text = model.BMCODE; this.lblBMNAME.Text = model.BMNAME; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MyERP.Model.PUB_BMTMP model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PUB_BMTMP set "); strSql.Append("BMCODE=@BMCODE,"); strSql.Append("BMNAME=@BMNAME"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@BMCODE", SqlDbType.NChar, 10), new SqlParameter("@BMNAME", SqlDbType.NChar, 10) }; parameters[0].Value = model.BMCODE; parameters[1].Value = model.BMNAME; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(MyERP.Model.PUB_BMTMP model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PUB_BMTMP("); strSql.Append("BMCODE,BMNAME)"); strSql.Append(" values ("); strSql.Append("@BMCODE,@BMNAME)"); SqlParameter[] parameters = { new SqlParameter("@BMCODE", SqlDbType.NChar, 10), new SqlParameter("@BMNAME", SqlDbType.NChar, 10) }; parameters[0].Value = model.BMCODE; parameters[1].Value = model.BMNAME; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtBMCODE.Text.Trim().Length == 0) { strErr += "BMCODE不能为空!\\n"; } if (this.txtBMNAME.Text.Trim().Length == 0) { strErr += "BMNAME不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string BMCODE = this.txtBMCODE.Text; string BMNAME = this.txtBMNAME.Text; MyERP.Model.PUB_BMTMP model = new MyERP.Model.PUB_BMTMP(); model.BMCODE = BMCODE; model.BMNAME = BMNAME; MyERP.BLL.PUB_BMTMP bll = new MyERP.BLL.PUB_BMTMP(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.PUB_BMTMP DataRowToModel(DataRow row) { MyERP.Model.PUB_BMTMP model = new MyERP.Model.PUB_BMTMP(); if (row != null) { if (row["BMCODE"] != null) { model.BMCODE = row["BMCODE"].ToString(); } if (row["BMNAME"] != null) { model.BMNAME = row["BMNAME"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.PUB_BMTMP GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 BMCODE,BMNAME from PUB_BMTMP "); strSql.Append(" where "); SqlParameter[] parameters = { }; MyERP.Model.PUB_BMTMP model = new MyERP.Model.PUB_BMTMP(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }