/// <summary> /// 获得数据列表 /// </summary> public List <TFXK.Model.Messages> DataTableToList(DataTable dt) { List <TFXK.Model.Messages> modelList = new List <TFXK.Model.Messages>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { TFXK.Model.Messages model; for (int n = 0; n < rowsCount; n++) { model = new TFXK.Model.Messages(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } model.title = dt.Rows[n]["title"].ToString(); model.userNames = dt.Rows[n]["userNames"].ToString(); model.userEmail = dt.Rows[n]["userEmail"].ToString(); model.msgContent = dt.Rows[n]["msgContent"].ToString(); model.qicq = dt.Rows[n]["qicq"].ToString(); if (dt.Rows[n]["stateid"].ToString() != "") { model.stateid = int.Parse(dt.Rows[n]["stateid"].ToString()); } model.recontent = dt.Rows[n]["recontent"].ToString(); if (dt.Rows[n]["createTime"].ToString() != "") { model.createTime = DateTime.Parse(dt.Rows[n]["createTime"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void btnSubmit_ServerClick(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtTitle.Value.Trim())) { TFXK.Common.Jscript.Alert("标题不能为空"); return; } if (string.IsNullOrWhiteSpace(txtContent.Value.Trim())) { TFXK.Common.Jscript.Alert("留言不能为空"); return; } if (string.IsNullOrWhiteSpace(txtUserName.Value.Trim())) { TFXK.Common.Jscript.Alert("联系人不能为空"); return; } if (string.IsNullOrWhiteSpace(txtUserPhone.Value.Trim())) { TFXK.Common.Jscript.Alert("联系方式不能为空"); return; } TFXK.Model.Messages message = new TFXK.Model.Messages(); message.title = txtTitle.Value.ToString(); message.msgContent = txtContent.Value.ToString(); message.userNames = txtUserName.Value.ToString(); message.userEmail = txtUserPhone.Value.ToString(); message.createTime = DateTime.Now; int i = bllMessage.Add(message); if (i > 0) { TFXK.Common.Jscript.AlertAndRedirect("添加成功", "Message.aspx"); } else { TFXK.Common.Jscript.Alert("添加失败"); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(TFXK.Model.Messages model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TFXK.Model.Messages model) { return(dal.Add(model)); }