Пример #1
0
        public bool Messages(Messaged message)
        {
            var success1 = false;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand();
                command.CommandText = $"insert into Message values('{message.Theme}','{message.Text}','{message.SenderId}')";
                command.Connection  = connection;

                if (command.ExecuteNonQuery() != 0)
                {
                    success1 = true;
                }
            }

            return(success1);
        }
Пример #2
0
        private void buttonWriteMess_Click(object sender, EventArgs e)
        {
            var message = new Messaged();

            message.Theme    = TB_MessageTheme.Text;
            message.Text     = RTB_MessageText.Text;
            message.SenderId = TB_SenderID.Text;

            var mailRepository = new MailRepository();

            if (mailRepository.Messages(message))
            {
                MessageBox.Show("Success!");
                this.SendToBack();
            }
            else
            {
                MessageBox.Show("Error!");
            }
        }