/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_Chat> DataTableToList(DataTable dt) { List <Tunnel.Model.Tunnel_Chat> modelList = new List <Tunnel.Model.Tunnel_Chat>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.Tunnel_Chat model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Chat(); //model.Chat_ID=dt.Rows[n]["Chat_ID"].ToString(); //model.Chat_UserID=dt.Rows[n]["Chat_UserID"].ToString(); model.Chat_UserName = dt.Rows[n]["Chat_UserName"].ToString(); model.Chat_Content = dt.Rows[n]["Chat_Content"].ToString(); if (dt.Rows[n]["Chat_Date"].ToString() != "") { model.Chat_Date = DateTime.Parse(dt.Rows[n]["Chat_Date"].ToString()); } if (dt.Rows[n]["Chat_State"].ToString() != "") { model.Chat_State = int.Parse(dt.Rows[n]["Chat_State"].ToString()); } //model.Chat_ToUserID=dt.Rows[n]["Chat_ToUserID"].ToString(); modelList.Add(model); } } return(modelList); }
protected void Button1_Click(object sender, EventArgs e) { try { Tunnel.Model.Tunnel_Chat tc = new Tunnel.Model.Tunnel_Chat(); Tunnel.BLL.Tunnel_Chat btc = new Tunnel.BLL.Tunnel_Chat(); string content = TextBox1.Text; string tomen = Request.Form["DropDownList1"]; int state = 0; if (tomen != "0") { if (CheckBox1.Checked) { state = 2; Tunnel.Model.Tunnel_Remind tr = new Tunnel.Model.Tunnel_Remind(); Tunnel.BLL.Tunnel_Remind br = new Tunnel.BLL.Tunnel_Remind(); tr.m_title = "您有一条聊天信息" + "<font color=red>(待读)</font>"; tr.m_url = "N_Chat/Default.aspx"; tr.m_touser = Convert.ToInt32(tomen); tr.m_time = DateTime.Now; tr.m_type = 2; tr.m_typeid = 2; tr.m_bid = 1; tr.m_callTime = DateTime.Now.AddSeconds(2); tr.m_isread = 0; long messge = br.Add(tr); } else { state = 1; } } Tunnel.BLL.UserLogin ul = new Tunnel.BLL.UserLogin(); ul.UsbnLogin = ul.getUserModel(ul.LoginID); tc.Chat_Content = content; tc.Chat_Date = DateTime.Now; tc.Chat_State = state; tc.Chat_UserID = ul.LoginID; tc.Chat_UserName = ul.UsbnLogin.m_name; tc.Chat_ToUserID = Convert.ToInt32(tomen); btc.Add(tc); Response.Redirect("Chat_Bottom.aspx"); } catch { return; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_Chat model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Chat model) { return(dal.Add(model)); }