private void OnlineUserLogin() { OnlineNegocio negocioOnline = new OnlineNegocio(Form1.Empresa.empconexao); tempo1 = DateTime.Now; TimeSpan min = tempo1 - tempo; if (this.Width > 215) { ChatOnlineInfo chatOn = new ChatOnlineInfo { chatident = ChatIdent(idchat, idLogado), chatidrecebe = idLogado }; colecaoChatNova = negocioOnline.ConsultarChatNova(chatOn); } if (min.Seconds > 10) { tempo = DateTime.Now; userOnlineColecao = negocioOnline.ConsultarUserOnline(idLogado); chatOnlineColecao = negocioOnline.ConsultarChatGridNovaMensagem(idLogado); } }
public ChatOnlineColecao ConsultarChatMensagemNova(int chatOn) { if (online.Conectar(EmpConexao)) { online.AddParametrosMySql("@recebe", chatOn); DataTable dataTable = online.dataTableMySql("spConsultarChatMensagemNova"); if (dataTable != null) { ChatOnlineColecao colecao = new ChatOnlineColecao(); foreach (DataRow chat in dataTable.Rows) { ChatOnlineInfo chatInfo = new ChatOnlineInfo { chatid = Convert.ToInt32(chat["quant"]), chatmessage = Convert.ToString(chat["uselogin"]) + " (" + Convert.ToInt32(chat["quant"]) + ")", chatidenvio = Convert.ToInt32(chat["chatidenvio"]), }; colecao.Add(chatInfo); } return(colecao); } else { return(null); } } else { return(null); } }
private void NovaMensagemChat() { if (infoChat != null) { negocioOnline = new OnlineNegocio(Form1.Empresa.empconexao); negocioOnline.InsertChat(infoChat); infoChat = null; } ChatOnlineInfo chatOn = new ChatOnlineInfo { chatident = ChatIdent(idchat, idLogado), chatidrecebe = idLogado }; negocioOnline = new OnlineNegocio(Form1.Empresa.empconexao); ChatOnlineColecao chat = negocioOnline.ConsultarChatNova(chatOn); if (chat != null) { negocioOnline = new OnlineNegocio(Form1.Empresa.empconexao); colecaoChat = negocioOnline.ConsultarChatOnline(ChatIdent(idchat, idLogado)); dataGridViewChat.ClearSelection(); negocioOnline = new OnlineNegocio(Form1.Empresa.empconexao); negocioOnline.UpdateChatMessageLida(ChatIdent(idchat, idLogado), idLogado); } }
private void NovaMensagem() { userConversa = userNegocio.ConsultarUsuarioId(idchat); labelNome.Text = userConversa.usenome; GridChat(); infoChat = null; textBoxMessage.Clear(); textBoxMessage.Select(); AbrirChat(); }
private void ItemSelecionado(object row, bool verdade) { if (verdade) { ChatOnlineInfo chat = (ChatOnlineInfo)row; idchat = chat.chatidenvio; } else { UserLoginInfo user = (UserLoginInfo)row; idchat = user.loginiduser; } NovaMensagem(); }
private void EnviarMensagem() { if (!string.IsNullOrEmpty(textBoxMessage.Text)) { infoChat = new ChatOnlineInfo { chatident = ChatIdent(idLogado, userConversa.useid), chatidenvio = idLogado, chatidrecebe = userConversa.useid, chatmessage = textBoxMessage.Text, }; textBoxMessage.Clear(); textBoxMessage.Select(); } }
public int InsertChat(ChatOnlineInfo chat) { if (online.Conectar(EmpConexao)) { online.AddParametrosMySql("@envio", chat.chatidenvio); online.AddParametrosMySql("@recebe", chat.chatidrecebe); online.AddParametrosMySql("@message", chat.chatmessage); online.AddParametrosMySql("@ident", chat.chatident); return(online.ExecutarScalarMySql("spInsertChat")); } else { return(0); } }
public ChatOnlineColecao ConsultarChatNova(ChatOnlineInfo chatOn) { if (online.Conectar(EmpConexao)) { online.AddParametrosMySql("@ident", chatOn.chatident); online.AddParametrosMySql("@recebe", chatOn.chatidrecebe); DataTable dataTable = online.dataTableMySql("spConsultarChatNova"); if (dataTable != null) { return(PreencherChatOnline(dataTable)); } else { return(null); } } else { return(null); } }
private ChatOnlineColecao PreencherChatOnline(DataTable dataTable) { ChatOnlineColecao chatcolecao = new ChatOnlineColecao(); foreach (DataRow chat in dataTable.Rows) { ChatOnlineInfo onlineInfo = new ChatOnlineInfo { chatdata = Convert.ToDateTime(chat["chatdata"]), chatid = Convert.ToInt32(chat["chatid"]), chatident = Convert.ToString(chat["chatident"]), chatidenvio = Convert.ToInt32(chat["chatidenvio"]), chatidrecebe = Convert.ToInt32(chat["chatidrecebe"]), chatlida = Convert.ToBoolean(chat["chatlida"]), chatmessage = Convert.ToString(chat["chatmessage"]) }; chatcolecao.Add(onlineInfo); } return(chatcolecao); }
private void EnviarMensagem() { if (!string.IsNullOrEmpty(textBoxMessage.Text)) { ChatOnlineInfo infoChat = new ChatOnlineInfo { chatident = ChatIdent(idLogado, userConversa.useid), chatidenvio = idLogado, chatidrecebe = userConversa.useid, chatmessage = textBoxMessage.Text, }; if (infoChat != null) { OnlineNegocio negocioOnline = new OnlineNegocio(Form1.Empresa.empconexao); negocioOnline.InsertChat(infoChat); IniciarChat(); } textBoxMessage.Clear(); textBoxMessage.Select(); } }