public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txt评价字典内容.Text.Trim().Length==0) { strErr+="评价字典内容不能为空!\\n"; } if(!PageValidate.IsNumber(txt对应分值.Text)) { strErr+="对应分值格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int 评价字典编号=int.Parse(this.lbl评价字典编号.Text); string 评价字典内容=this.txt评价字典内容.Text; int 对应分值=int.Parse(this.txt对应分值.Text); la.Model.comment_dic model=new la.Model.comment_dic(); model.评价字典编号=评价字典编号; model.评价字典内容=评价字典内容; model.对应分值=对应分值; la.BLL.comment_dic bll=new la.BLL.comment_dic(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.comment_dic DataRowToModel(DataRow row) { la.Model.comment_dic model=new la.Model.comment_dic(); if (row != null) { if(row["评价字典编号"]!=null && row["评价字典编号"].ToString()!="") { model.评价字典编号=int.Parse(row["评价字典编号"].ToString()); } if(row["评价字典内容"]!=null) { model.评价字典内容=row["评价字典内容"].ToString(); } if(row["对应分值"]!=null && row["对应分值"].ToString()!="") { model.对应分值=int.Parse(row["对应分值"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.comment_dic GetModel(int 评价字典编号) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 评价字典编号,评价字典内容,对应分值 from comment_dic "); strSql.Append(" where 评价字典编号=@评价字典编号 "); SqlParameter[] parameters = { new SqlParameter("@评价字典编号", SqlDbType.Int,4) }; parameters[0].Value = 评价字典编号; la.Model.comment_dic model=new la.Model.comment_dic(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }