protected void Btnadd_Click(object sender, EventArgs e) { if (Request.QueryString["Gid"] != null) { string Mgid = Request.QueryString["Gid"].ToString(); string Mitem = TextBoxMitem.Text.Trim(); if (!string.IsNullOrEmpty(Mitem)) { LearnSite.Model.GaugeItem mmodel = new LearnSite.Model.GaugeItem(); mmodel.Mgid = Int32.Parse(Mgid); mmodel.Mitem = Mitem; mmodel.Mscore = Int32.Parse(DDLscore.SelectedValue); mmodel.Msort = Int32.Parse(DDLsort.SelectedValue); LearnSite.BLL.GaugeItem mbll = new LearnSite.BLL.GaugeItem(); mbll.Add(mmodel); System.Threading.Thread.Sleep(200); showGaugeItem(); TextBoxMitem.Text = ""; } else { LearnSite.Common.WordProcess.Alert("请输入评价描述!", this.Page); } } }
protected void GVGaugeItem_RowUpdating(object sender, GridViewUpdateEventArgs e) { string mid = GVGaugeItem.DataKeys[GVGaugeItem.EditIndex][0].ToString(); string item = ((TextBox)(GVGaugeItem.Rows[e.RowIndex].FindControl("TextBoxMitem"))).Text.Trim(); string score = ((TextBox)(GVGaugeItem.Rows[e.RowIndex].FindControl("TextBoxMscore"))).Text.Trim(); if (LearnSite.Common.WordProcess.IsIntNum(score)) { LearnSite.Model.GaugeItem gmodel = new LearnSite.Model.GaugeItem(); gmodel.Mid = Int32.Parse(mid); gmodel.Mitem = item; gmodel.Mscore = Int32.Parse(score); LearnSite.BLL.GaugeItem gbll = new LearnSite.BLL.GaugeItem(); if (gbll.UpdateMitem(gmodel))//更新修改 { GVGaugeItem.EditIndex = -1; showGaugeItem(); } } else { LearnSite.Common.WordProcess.Alert("分值请输入数字!", this.Page); } }
/// <summary> /// 获得数据列表 /// </summary> public List <LearnSite.Model.GaugeItem> DataTableToList(DataTable dt) { List <LearnSite.Model.GaugeItem> modelList = new List <LearnSite.Model.GaugeItem>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.GaugeItem model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.GaugeItem(); if (dt.Rows[n]["Mid"] != null && dt.Rows[n]["Mid"].ToString() != "") { model.Mid = int.Parse(dt.Rows[n]["Mid"].ToString()); } if (dt.Rows[n]["Mgid"] != null && dt.Rows[n]["Mgid"].ToString() != "") { model.Mgid = int.Parse(dt.Rows[n]["Mgid"].ToString()); } if (dt.Rows[n]["Mitem"] != null && dt.Rows[n]["Mitem"].ToString() != "") { model.Mitem = dt.Rows[n]["Mitem"].ToString(); } if (dt.Rows[n]["Mscore"] != null && dt.Rows[n]["Mscore"].ToString() != "") { model.Mscore = int.Parse(dt.Rows[n]["Mscore"].ToString()); } if (dt.Rows[n]["Msort"] != null && dt.Rows[n]["Msort"].ToString() != "") { model.Msort = int.Parse(dt.Rows[n]["Msort"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 注意: model只赋值Mitem,Mscore,Mid /// </summary> public bool UpdateMitem(LearnSite.Model.GaugeItem model) { return(dal.UpdateMitem(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LearnSite.Model.GaugeItem model) { return(dal.Add(model)); }