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