protected void btnAddNew_Click(object sender, EventArgs e) { ScoreRuleModel smodel = new ScoreRuleModel(); smodel.ActionType = NoName.Utility.input.Filter(txtActionType.Text.Trim()); smodel.Score = int.Parse(txtScore.Text.Trim()); smodel.Remark = NoName.Utility.input.Filter(txtRemark.Text.Trim()); sbll.Save(smodel); txtRemark.Text = ""; txtActionType.Text = ""; txtScore.Text = ""; BindList(); }
protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in gvList.Rows) { if (row.RowType == DataControlRowType.DataRow) { string actiontype = gvList.DataKeys[row.RowIndex].Value.ToString(); ScoreRuleModel model = sbll.GetModel(actiontype); model.Remark = ((TextBox)row.FindControl("txtRemark")).Text.Trim(); model.Score = int.Parse(((TextBox)row.FindControl("txtScore")).Text); sbll.Save(model); } } BindList(); }
/// <summary> /// 对象实体绑定数据 /// </summary> public ScoreRuleModel ReaderBind(IDataReader dataReader) { ScoreRuleModel model = new ScoreRuleModel(); object ojb; model.ActionType = dataReader["actiontype"].ToString(); ojb = dataReader["score"]; if (ojb != null && ojb != DBNull.Value) { model.Score = Convert.ToInt32(ojb); } model.Remark = dataReader["remark"].ToString(); ojb = dataReader["inserttime"]; if (ojb != null && ojb != DBNull.Value) { model.InsertTime = Convert.ToDateTime(ojb); } ojb = dataReader["updatetime"]; if (ojb != null && ojb != DBNull.Value) { model.UpdateTime = Convert.ToDateTime(ojb); } return model; }
/// <summary> /// 增加一条数据 /// </summary> public void Save(ScoreRuleModel model) { Database db = CommDataAccess.DbWriter; DbCommand dbCommand = db.GetStoredProcCommand("UP_ScoreRule_Save"); db.AddInParameter(dbCommand, "actiontype", DbType.AnsiString, model.ActionType); db.AddInParameter(dbCommand, "score", DbType.Int32, model.Score); db.AddInParameter(dbCommand, "remark", DbType.AnsiString, model.Remark); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 增加一条数据 /// </summary> public void Save(ScoreRuleModel model) { dal.Save(model); }