/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.LeaveWord> DataTableToList(DataTable dt) { List <Tunnel.Model.LeaveWord> modelList = new List <Tunnel.Model.LeaveWord>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.LeaveWord model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.LeaveWord(); if (dt.Rows[n]["lw_Id"].ToString() != "") { model.lw_Id = int.Parse(dt.Rows[n]["lw_Id"].ToString()); } if (dt.Rows[n]["lw_SetDate"].ToString() != "") { model.lw_SetDate = DateTime.Parse(dt.Rows[n]["lw_SetDate"].ToString()); } model.lw_Content = dt.Rows[n]["lw_Content"].ToString(); if (dt.Rows[n]["lw_UserId"].ToString() != "") { model.lw_UserId = int.Parse(dt.Rows[n]["lw_UserId"].ToString()); } if (dt.Rows[n]["lw_VateId"].ToString() != "") { model.lw_VateId = int.Parse(dt.Rows[n]["lw_VateId"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 发送信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void button_Click(object sender, EventArgs e) { //添加信息 string YourWord = this.txtYourword.Text; int uid = ulBLL.LoginID; if (!string.IsNullOrEmpty(Request.QueryString["v_id"]) && !string.IsNullOrEmpty(YourWord)) { int vote_Id = int.Parse(Request.QueryString["v_id"].ToString()); Tunnel.Model.LeaveWord leaveWordModel = new Tunnel.Model.LeaveWord(); leaveWordModel.lw_SetDate = DateTime.Now; leaveWordModel.lw_UserId = uid; leaveWordModel.lw_VateId = vote_Id; leaveWordModel.lw_Content = YourWord; leaveWordDAL.Add(leaveWordModel); //新增一条评论 ClientScript.RegisterStartupScript(this.GetType(), "str", "alert('发表评论成功!')", true); txtYourword.Text = ""; LoadData(); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.LeaveWord model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Tunnel.Model.LeaveWord model) { dal.Add(model); }