You are on page 1of 2

using using using using using using

System; System.Collections.Generic; System.Linq; System.Text; System.Data.SqlClient; System.Data;

namespace WinChat { public class MetChat { public int InserirNick(string Nome) { int R = 0; string Sql = "insert into tbusuarios(usuario)"; Sql += "values('" + Nome + "')"; ClsDAO DAO = new ClsDAO(); R = DAO.Inserir(Sql); return R; } public List<PropChat> RetornaMensagens(DateTime Entrada) { List<PropChat> LPC = new List<PropChat>(); PropChat PC = null; string Sql = "select * from tbchat "; Sql += "where dataupdate >='" + Entrada + "'"; DataTable DT = new DataTable(); ClsDAO DAO = new ClsDAO(); DT = DAO.RetDatatable(Sql); for (int i = 0; i < DT.Rows.Count; i++) { PC = new PropChat(); PC.IdChat = Convert.ToInt32(DT.Rows[i]["idchat"]); PC.IdRemetente = Convert.ToInt32(DT.Rows[i]["idremetente"]); PC.NomeDestinatario1 = DT.Rows[i]["nomedestinatario"].ToString() ; PC.Mensagem = DT.Rows[i]["mensagem"].ToString(); PC.IdDestinatario = Convert.ToInt32(DT.Rows[i]["iddestinatario"] ); PC.NomeRemetente = DT.Rows[i]["nomeremetente"].ToString(); PC.DataUpdate = Convert.ToDateTime(DT.Rows[i]["dataupdate"]); LPC.Add(PC); } return LPC; } public void EnviarMensagem(int IdRemetente, string NomeRemetente, int Id Destinatario, string Mensagem) { ClsDAO DAO = new ClsDAO();

string Sql += Sql += Sql += Sql += Sql += }

Sql = "insert into tbchat(idremetente, "; "nomeremetente, iddestinatario, mensagem) "; "values(" + IdRemetente + ","; "'" + NomeRemetente + "',"; IdDestinatario + ","; "'" + Mensagem + "')";

DAO.Inserir(Sql); public int DeletaUsuario(int Id) { int R = 0; string Sql = "delete from tbusuarios where idusuario" +Id; ClsDAO DAO = new ClsDAO(); R = DAO.Inserir(Sql); return R; } } }

You might also like