Exemplo n.º 1
0
        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");
                    }
                }
            }
        }
Exemplo n.º 2
0
        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
            }
        }
Exemplo n.º 3
0
        private void btnSendMessage_Click(object sender, EventArgs e)
        {
            string res = SqlLibrary.SendMessage(CurrUserEmail, CurrUserFirstName, CurrUserLastName, rtbMessage.Text);

            if (res != "")
            {
                MessageBox.Show(res);
            }
        }
Exemplo n.º 4
0
        void StartCheckingForNewMessages()
        {
            long messages = SqlLibrary.CountOfMessages();

            if (messages > CurrCountOfMessages)
            {
                CurrCountOfMessages = messages;
                StartUpdateChat();
            }

            RefreshInfo(messages);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        private void btnRegistration_Click(object sender, EventArgs e)
        {
            string res = SqlLibrary.RegistrationOfNewUser(tbEmail.Text, tbPassword.Text, tbFirstName.Text, tbLastName.Text);

            MessageBox.Show(res);
        }