private void SendQuery() { DataTable dt = null; bool isError = false; try { dt = SqlLibrary.ExecuteQuery(rtbQuery.Text); } catch (Exception ex) { rtbSqlResponse.AppendText("Произошла ошибка при обработке SQL запроса :( \n"); rtbSqlResponse.AppendText(ex.Message + "\n"); isError = true; } if (!isError) { rtbSqlResponse.AppendText("Запрос выполнен успешно! :) \n"); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { rtbSqlResponse.AppendText(dt.Rows[i].ItemArray[j] + " "); } rtbSqlResponse.AppendText("\n"); } } } }
private void RefreshChatControl() { DataTable dt = SqlLibrary.GetAllMessages(); try { BeginInvoke(new MethodInvoker( delegate { rtbChat.Clear(); if (dt != null) { foreach (DataRow record in dt.Rows) { rtbChat.AppendText(record[5] + "\n"); rtbChat.AppendText(String.Format("{0} {1} ({2}) написал(а) : \n", record[2], record[3], record[1])); rtbChat.AppendText(record[4] + "\n"); rtbChat.AppendText("\n"); } rtbChat.SelectionStart = rtbChat.Text.Length - 1; rtbChat.SelectionLength = 0; } })); } catch { // ignored } }
private void btnSendMessage_Click(object sender, EventArgs e) { string res = SqlLibrary.SendMessage(CurrUserEmail, CurrUserFirstName, CurrUserLastName, rtbMessage.Text); if (res != "") { MessageBox.Show(res); } }
void StartCheckingForNewMessages() { long messages = SqlLibrary.CountOfMessages(); if (messages > CurrCountOfMessages) { CurrCountOfMessages = messages; StartUpdateChat(); } RefreshInfo(messages); }
private void btnLogin_Click(object sender, EventArgs e) { DataTable dt = SqlLibrary.Login(tbEmail.Text, tbPassword.Text); if (dt == null || dt.Rows.Count != 1) { MessageBox.Show("Вход не выполнен :("); } else { tbPassword.Text = ""; tbEmail.Text = ""; gbLogin.Visible = false; gbSendMessage.Enabled = true; CurrUserEmail = dt.Rows[0].ItemArray[0].ToString(); CurrUserFirstName = dt.Rows[0].ItemArray[2].ToString(); CurrUserLastName = dt.Rows[0].ItemArray[3].ToString(); lblUser.Text = String.Format("{0} {1} ({2})", CurrUserFirstName, CurrUserLastName, CurrUserEmail); } }
private void btnRegistration_Click(object sender, EventArgs e) { string res = SqlLibrary.RegistrationOfNewUser(tbEmail.Text, tbPassword.Text, tbFirstName.Text, tbLastName.Text); MessageBox.Show(res); }