public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtManageFareTypeID.Text)) { strErr += "ManageFareTypeID格式错误!\\n"; } if (this.txtManageFareTypeName.Text.Trim().Length == 0) { strErr += "1按月2按面积3按人口4手工输不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int ManageFareTypeID = int.Parse(this.txtManageFareTypeID.Text); string ManageFareTypeName = this.txtManageFareTypeName.Text; WebDemo.Model.WebDemo.ManageFareType model = new WebDemo.Model.WebDemo.ManageFareType(); model.ManageFareTypeID = ManageFareTypeID; model.ManageFareTypeName = ManageFareTypeName; WebDemo.BLL.WebDemo.ManageFareType bll = new WebDemo.BLL.WebDemo.ManageFareType(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
private void ShowInfo() { WebDemo.BLL.WebDemo.ManageFareType bll = new WebDemo.BLL.WebDemo.ManageFareType(); WebDemo.Model.WebDemo.ManageFareType model = bll.GetModel(); this.txtManageFareTypeID.Text = model.ManageFareTypeID.ToString(); this.txtManageFareTypeName.Text = model.ManageFareTypeName; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.ManageFareType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ManageFareType set "); strSql.Append("ManageFareTypeID=@ManageFareTypeID,"); strSql.Append("ManageFareTypeName=@ManageFareTypeName"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@ManageFareTypeID", SqlDbType.Int, 4), new SqlParameter("@ManageFareTypeName", SqlDbType.VarChar, 50) }; parameters[0].Value = model.ManageFareTypeID; parameters[1].Value = model.ManageFareTypeName; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WebDemo.Model.WebDemo.ManageFareType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ManageFareType("); strSql.Append("ManageFareTypeID,ManageFareTypeName)"); strSql.Append(" values ("); strSql.Append("@ManageFareTypeID,@ManageFareTypeName)"); SqlParameter[] parameters = { new SqlParameter("@ManageFareTypeID", SqlDbType.Int, 4), new SqlParameter("@ManageFareTypeName", SqlDbType.VarChar, 50) }; parameters[0].Value = model.ManageFareTypeID; parameters[1].Value = model.ManageFareTypeName; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.ManageFareType DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.ManageFareType model = new WebDemo.Model.WebDemo.ManageFareType(); if (row != null) { if (row["ManageFareTypeID"] != null && row["ManageFareTypeID"].ToString() != "") { model.ManageFareTypeID = int.Parse(row["ManageFareTypeID"].ToString()); } if (row["ManageFareTypeName"] != null) { model.ManageFareTypeName = row["ManageFareTypeName"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.ManageFareType GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ManageFareTypeID,ManageFareTypeName from ManageFareType "); strSql.Append(" where "); SqlParameter[] parameters = { }; WebDemo.Model.WebDemo.ManageFareType model = new WebDemo.Model.WebDemo.ManageFareType(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }