コード例 #1
0
ファイル: MOD_Employee.cs プロジェクト: MRkalandos/mrkalandos
        private void metroButton1_Click(object sender, EventArgs e)
        {
            var filedialog = new OpenFileDialog();

            filedialog.Filter = @"JPG (*.jpg)|*.jpg|PNG (*.png)|*.png";
            if (filedialog.ShowDialog() == DialogResult.OK)
            {
                var fileName   = filedialog.SafeFileName;
                var sourcePath = filedialog.FileName;
                var targetPath = @"PhotoEmployee";
                if (!Directory.Exists(targetPath))
                {
                    Directory.CreateDirectory(targetPath);
                }
                var destFile = Path.Combine(targetPath, fileName);
                try
                {
                    File.Copy(sourcePath, destFile, true);
                    metroTextBox6.Text = Path.GetFileName(fileName);
                }
                catch (Exception exception)
                {
                    MetroMessageBox.Show(this, "\nПапка задействована, фото может быть не установлено",
                                         TitleException, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    HelperLog.Write(exception.ToString());
                    metroTextBox6.Text = Path.GetFileName(fileName);
                }
                finally
                {
                    FocusMe();
                }
            }
        }
コード例 #2
0
ファイル: ViewTrening.cs プロジェクト: MRkalandos/mrkalandos
        private void metroButton1_Click(object sender, EventArgs e)
        {
            var objViewTreningAdd = new ModViewTrenerovka
            {
                textBox1    = { Text = "" }, Text = @"Добавить тренировку", button1 = { Text = @"Добавить" },
                metroLabel1 = { Text = Convert.ToString(ViewmetroGrid1.CurrentRow.Cells[0].Value) }
            };

            if (objViewTreningAdd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    connection.Open();
                    var queryAddViewTtrening = new OleDbCommand(@"INSERT INTO [Вид_тренировки]
                                                                      ( название)
                                                                       VALUES(@name)", connection);
                    queryAddViewTtrening.Parameters.AddWithValue("name", objViewTreningAdd.textBox1.Text);
                    queryAddViewTtrening.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    HelperLog.Write(exception.ToString());
                }
            }
コード例 #3
0
 public void UpdateVisits()
 {
     try
     {
         dataAdapterVisits = new OleDbDataAdapter(
             @"SELECT  Учет_посещений.Идпосещений , Спортсмен.Фамилия, Абонемент.Название, Продажа_абонемента.Дата_начала as [Дата начала], Продажа_абонемента.Дата_окончания as [Дата окончания], Учет_посещений.Дата as [Дата посещения],Учет_посещений.идпродажа
                          FROM Абонемент
                          INNER JOIN ((Спортсмен INNER JOIN Продажа_абонемента 
                          ON Спортсмен.Идспортсмен = Продажа_абонемента.Идспортсмен) INNER JOIN Учет_посещений 
                          ON Продажа_абонемента.Идпродажа = Учет_посещений.Идпродажа) 
                          ON Абонемент.Идабонемент = Продажа_абонемента.Идабонемент;",
             connection);
         dataTableVisits = new DataTable();
         dataAdapterVisits.Fill(dataTableVisits);
         VISITSGrid.DataSource         = dataTableVisits;
         VISITSGrid.Columns[0].Visible = false;
         VISITSGrid.Columns[6].Visible = false;
         VISITSGrid.Sort(VISITSGrid.Columns[1], ListSortDirection.Ascending);
         VISITSGrid.Select();
         VISITSGrid.AllowUserToAddRows = false;
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #4
0
ファイル: Money.cs プロジェクト: MRkalandos/mrkalandos
        private void button1_Click(object sender, EventArgs e)
        {
            var objMoneyAdd = new ModMoney
            {
                textBox1    = { Text = "" }, Text = @"Добавить зарплату", button1 = { Text = @"Добавить" },
                metroLabel1 = { Text = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value) }
            };

            if (objMoneyAdd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    connection.Open();
                    var queryAddMoney = new OleDbCommand(@"INSERT INTO [Зарплата_сотрудника]
                                                        ( Зарплата)
                                                        VALUES(@money)", connection);
                    queryAddMoney.Parameters.AddWithValue("money", objMoneyAdd.textBox1.Text);
                    queryAddMoney.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    HelperLog.Write(exception.ToString());
                }
            }
コード例 #5
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     try
     {
         if (File.Exists("Help/Help.chm"))
         {
             Help.ShowHelp(null, "Help/Help.chm");
         }
         else
         {
             MetroMessageBox.Show(this, "Файл не найден", TitleException, MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
         }
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #6
0
        private void metroTile1_Click(object sender, EventArgs e)
        {
            try
            {
                if ((textBox1.Text == "") ||
                    (metroComboBox1.Text == "") ||
                    (metroComboBox2.Text == ""))

                {
                    MetroMessageBox.Show(this, "\nНе все поля заполнены", "Корректность",
                                         MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
            catch (Exception exception)
            {
                MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                HelperLog.Write(exception.ToString());
            }
            finally
            {
                FocusMe();
            }
        }
コード例 #7
0
ファイル: ViewTrening.cs プロジェクト: MRkalandos/mrkalandos
 private void View_trenerovki_Load(object sender, EventArgs e)
 {
     try
     {
         UpdateViewTrening();
         FocusMe();
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
 }
コード例 #8
0
 private void metroTile1_Click(object sender, EventArgs e)
 {
     try
     {
         if ((textBox1.Text == "") ||
             (textBox2.Text == "") ||
             (textBox3.Text == "") ||
             (maskedTextBox1.Text == "") ||
             (metroTextBox4.Text == "") ||
             (metroTextBox5.Text == "") ||
             (metroTextBox1.Text == ""))
         {
             MetroMessageBox.Show(this, "\nНе все поля заполнены", "Корректность",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             connection.Open();
             var queryFindClone = new OleDbCommand(@"select *  
                                                               from [тренер] 
                                                               where пароль=@pass and
                                                             идтренер <> " + Convert.ToInt32(label1.Text) + "",
                                                   connection);
             queryFindClone.Parameters.AddWithValue("pass", metroTextBox5.Text);
             queryFindClone.ExecuteNonQuery();
             if (queryFindClone.ExecuteScalar() != null)
             {
                 MetroMessageBox.Show(this, "\nТакой пароль уже существует", TitleException,
                                      MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
             }
         }
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
         connection.Close();
     }
 }
コード例 #9
0
 private void VISITS_Load(object sender, EventArgs e)
 {
     try
     {
         UpdateVisits();
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #10
0
 private void metroTile1_Click(object sender, EventArgs e)
 {
     if ((textBox1.Text == "") ||
         (textBox2.Text == "") ||
         (textBox3.Text == "") ||
         (metroComboBox1.Text == ""))
     {
         MetroMessageBox.Show(this, "\nНе все поля заполнены", TitleException,
                              MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             connection.Open();
             var queryFindCloneAbonement = new OleDbCommand(@"select *  
                                                               from [Абонемент] 
                                                               where Название=@name
                                                               and идабонемент <> " +
                                                            Convert.ToInt32(metroLabel4.Text) + "", connection);
             queryFindCloneAbonement.Parameters.AddWithValue("name", textBox1.Text);
             queryFindCloneAbonement.ExecuteNonQuery();
             if (queryFindCloneAbonement.ExecuteScalar() != null)
             {
                 MetroMessageBox.Show(this, "\nТакое название уже существует", TitleException,
                                      MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
             }
         }
         catch (Exception exception)
         {
             MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
             HelperLog.Write(exception.ToString());
         }
         finally
         {
             FocusMe();
             connection.Close();
         }
     }
 }
コード例 #11
0
ファイル: Money.cs プロジェクト: MRkalandos/mrkalandos
 private void Money_Load(object sender, EventArgs e)
 {
     try
     {
         this.FormBorderStyle = FormBorderStyle.None;
         UpdateMoney();
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #12
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            var objVisiTeAdd = new MOD_VISITS {
                Text = @"Добавить посещение", metroTile1 = { Text = @"Добавить" }
            };

            connection.Open();
            var dbCommandVisit = new OleDbCommand(@"SELECT Продажа_абонемента.Идпродажа, Спортсмен.Фамилия
FROM Спортсмен INNER JOIN Продажа_абонемента ON Спортсмен.Идспортсмен = Продажа_абонемента.Идспортсмен;", connection);

            objVisiTeAdd.metroComboBox1.DisplayMember = "Спортсмен.Фамилия";
            var reader = dbCommandVisit.ExecuteReader();
            var list   = new Dictionary <int, string>();

            while (reader.Read())
            {
                list.Add((int)reader[0], (string)reader[1]);
            }
            reader.Close();
            dbCommandVisit.ExecuteNonQuery();
            objVisiTeAdd.metroComboBox1.DataSource    = list.ToList();
            objVisiTeAdd.metroComboBox1.DisplayMember = "Value";
            objVisiTeAdd.metroComboBox1.ValueMember   = "Key";
            if (objVisiTeAdd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    VISITSGrid.Sort(VISITSGrid.Columns[1], ListSortDirection.Ascending);
                    var queryInsertVisit = new OleDbCommand(@"INSERT INTO [учет_посещений]
                                                        ( Дата,Идпродажа)
                                                        VALUES(@sdate,@idsale)", connection);
                    queryInsertVisit.Parameters.AddWithValue("date",
                                                             Convert.ToDateTime(objVisiTeAdd.metroDateTime1.Text));
                    queryInsertVisit.Parameters.AddWithValue("idsale",
                                                             Convert.ToInt32(objVisiTeAdd.metroComboBox1.SelectedValue.ToString()));
                    queryInsertVisit.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    HelperLog.Write(exception.ToString());
                }
            }
コード例 #13
0
ファイル: MOD_Money.cs プロジェクト: MRkalandos/mrkalandos
 private void button1_Click(object sender, EventArgs e)
 {
     if ((textBox1.Text == ""))
     {
         MetroMessageBox.Show(this, "\nНе все поля заполнены", TitleException,
                              MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             connection.Open();
             var sss1 = new OleDbCommand(@"select зарплата  
                                          from [зарплата_сотрудника] 
                                              where зарплата=@st1 
                                                and идзарплата <> " + Convert.ToInt32(metroLabel1.Text) + "",
                                         connection);
             sss1.Parameters.AddWithValue("st1", textBox1.Text);
             sss1.ExecuteNonQuery();
             if (sss1.ExecuteScalar() != null)
             {
                 MetroMessageBox.Show(this, "\nТакая зарплата уже существует", "Корректность",
                                      MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
             }
         }
         catch (Exception exception)
         {
             MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
             HelperLog.Write(exception.ToString());
         }
         finally
         {
             FocusMe();
             connection.Close();
         }
     }
 }
コード例 #14
0
ファイル: SendComment.cs プロジェクト: MRkalandos/mrkalandos
        private void Send_Mail_Load(object sender, EventArgs e)
        {
            try
            {
                var internetStatus = IPStatus.TimedOut;
                try
                {
                    var ping     = new Ping();
                    var testSite = ping.Send(@"mail.ru");
                    if (testSite != null)
                    {
                        internetStatus = testSite.Status;
                    }
                }
                catch (Exception exception)
                {
                    HelperLog.Write(exception.ToString());
                    FocusMe();
                }

                if (internetStatus != IPStatus.Success)
                {
                    MetroMessageBox.Show(this, "Интернет-соединение отсутсвует, сообщение не отправиться",
                                         "Соединение не установлено", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    FocusMe();
                }
                else
                {
                    MetroMessageBox.Show(this, "Интернет-соединение установлено, сообщение отправиться",
                                         "Соединение установлено", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FocusMe();
                }
            }
            catch (Exception exception)
            {
                MetroMessageBox.Show(this, "Сообщение не отправлено на почту" + metroTextBox4.Text, "Не отправлено",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);

                HelperLog.Write(exception.ToString());
                FocusMe();
            }
        }
コード例 #15
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if ((textBox1.Text == ""))
         {
             MetroMessageBox.Show(this, "\nНе все поля заполнены", "Корректность",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             connection.Open();
             var queryFindClone = new OleDbCommand(@"select *  
                                                               from [Вид_тренировки] 
                                                               where название=@name 
                                                               and идвидтренировка <> " +
                                                   Convert.ToInt32(metroLabel1.Text) + "", connection);
             queryFindClone.Parameters.AddWithValue("name", textBox1.Text);
             queryFindClone.ExecuteNonQuery();
             if (queryFindClone.ExecuteScalar() != null)
             {
                 MetroMessageBox.Show(this, "\nТакой вид тренировки уже существует",
                                      TitleException, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
             }
         }
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         connection.Close();
         FocusMe();
     }
 }
コード例 #16
0
ファイル: SendComment.cs プロジェクト: MRkalandos/mrkalandos
 private void metroTile1_Click(object sender, EventArgs e)
 {
     try
     {
         attachment = true;
         var dialog = new OpenFileDialog();
         if (dialog.ShowDialog() != DialogResult.OK)
         {
             attachment = false;
         }
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #17
0
ファイル: ViewTrening.cs プロジェクト: MRkalandos/mrkalandos
 public void UpdateViewTrening()
 {
     try
     {
         dataAdapterViewTrening =
             new OleDbDataAdapter(@"SELECT Вид_тренировки.* FROM Вид_тренировки;", connection);
         dataTableViewTrening = new DataTable();
         dataAdapterViewTrening.Fill(dataTableViewTrening);
         ViewmetroGrid1.DataSource         = dataTableViewTrening;
         ViewmetroGrid1.Columns[0].Visible = false;
         ViewmetroGrid1.Sort(ViewmetroGrid1.Columns[1], ListSortDirection.Ascending);
         ViewmetroGrid1.Select();
         ViewmetroGrid1.AllowUserToAddRows = false;
         FocusMe();
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
 }
コード例 #18
0
 private void RepAbone_ent_Load(object sender, EventArgs e)
 {
     try
     {
         var connection = new OleDbConnection(ConnectionDb.conString());
         connection.Open();
         var adapter = new OleDbDataAdapter(@"select * from абонемент", connection);
         adapter.Fill(REPAbonement.Абонемент);
         connection.Close();
         this.reportViewer1.RefreshReport();
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FormBorderStyle = FormBorderStyle.None;
            this.Activate();
            metroComboBox1.SelectedIndex = 0;
            if (File.Exists(Directory.GetParent(Directory.GetCurrentDirectory())
                            .Parent?.FullName + "/ISgym.mdb"))
            {
            }
            else
            {
                try
                {
                    MetroMessageBox.Show(this, "Файл базы данных не найден укажите новый путь", "Файл БД не найден",
                                         MessageBoxButtons.OK, MessageBoxIcon.Error);
                    var openFileDialog1 = new OpenFileDialog()
                    {
                        Filter = @"Файл БД (*.mdb)|*.mdb"
                    };
                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        _filename = openFileDialog1.FileName;
                        File.Copy(_filename, Directory.GetParent(Directory.GetCurrentDirectory())
                                  .Parent?.FullName + "/ISgym.mdb");
                    }

                    FocusMe();
                }
                catch (Exception exception)
                {
                    MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    HelperLog.Write(exception.ToString());
                    FocusMe();
                }
            }
        }
コード例 #20
0
 private void metroButton3_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MetroMessageBox.Show(this, "\nУдалить запись?", "Удалить?",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
     {
         if (VISITSGrid.RowCount == 0)
         {
             MetroMessageBox.Show(this, "Записей больше нет", "Таблица пуста", MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
         }
         else
         {
             try
             {
                 connection.Open();
                 Debug.Assert(VISITSGrid.CurrentRow != null, "Таблица пуста");
                 var idVisit          = Convert.ToInt32(VISITSGrid.CurrentRow.Cells[0].Value);
                 var queryDeleteVisit = new OleDbCommand(@"DELETE FROM учет_посещений 
                                             WHERE идпосещений=" + idVisit + "", connection);
                 queryDeleteVisit.ExecuteNonQuery();
                 VISITSGrid.Sort(VISITSGrid.Columns[1], ListSortDirection.Ascending);
                 UpdateVisits();
             }
             catch (Exception exception)
             {
                 MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                      MessageBoxIcon.Error);
                 HelperLog.Write(exception.ToString());
             }
             finally
             {
                 connection.Close();
                 FocusMe();
             }
         }
     }
 }
コード例 #21
0
ファイル: ViewTrening.cs プロジェクト: MRkalandos/mrkalandos
 private void metroButton3_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes == MetroMessageBox.Show(this, "\nУдалить запись?", "Удалить?",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
     {
         try
         {
             if (ViewmetroGrid1.RowCount == 0)
             {
                 MetroMessageBox.Show(this, "Записей больше нет", "Таблица пуста", MessageBoxButtons.OK,
                                      MessageBoxIcon.Error);
             }
             else
             {
                 connection.Open();
                 var idViewTrening           = Convert.ToInt32(ViewmetroGrid1.CurrentRow.Cells[0].Value);
                 var queryDeleteViewTtrening = new OleDbCommand(@"DELETE FROM Вид_тренировки 
                                                                  WHERE идвидтренировка=" + idViewTrening + "",
                                                                connection);
                 queryDeleteViewTtrening.ExecuteNonQuery();
                 ViewmetroGrid1.Sort(ViewmetroGrid1.Columns[1], ListSortDirection.Ascending);
                 UpdateViewTrening();
             }
         }
         catch (Exception exception)
         {
             MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
             HelperLog.Write(exception.ToString());
         }
         finally
         {
             connection.Close();
             FocusMe();
         }
     }
 }
コード例 #22
0
ファイル: Money.cs プロジェクト: MRkalandos/mrkalandos
 public void UpdateMoney()
 {
     try
     {
         dataAdapterMoney = new OleDbDataAdapter(@"SELECT * from зарплата_сотрудника;", connection);
         dataTableMoney   = new DataTable();
         dataAdapterMoney.Fill(dataTableMoney);
         dataGridView1.DataSource         = dataTableMoney;
         dataGridView1.Columns[0].Visible = false;
         dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Ascending);
         dataGridView1.Select();
         dataGridView1.AllowUserToAddRows = false;
     }
     catch (Exception exception)
     {
         MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
         HelperLog.Write(exception.ToString());
     }
     finally
     {
         FocusMe();
     }
 }
コード例 #23
0
        private void metroTile1_Click(object sender, EventArgs e)
        {
            try
            {
                if (metroTextBox1.Text == "")
                {
                    MetroMessageBox.Show(this, "\nЗаполните поле пароль", TitleException, MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                }
                else
                {
                    connection.Open();
                    switch (metroComboBox1.SelectedIndex)
                    {
                    case 0:
                        var auth = new OleDbCommand("SELECT * FROM сотрудник WHERE должность = ? AND пароль = ?",
                                                    connection);
                        auth.Parameters.AddWithValue("должность", metroComboBox1.Text);
                        auth.Parameters.AddWithValue("пароль", metroTextBox1.Text);
                        if (auth.ExecuteScalar() != null || metroTextBox1.Text == @"316206")
                        {
                            MetroMessageBox.Show(this, "\nВход выполнен: Администратор", "Вход в систему",
                                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Opacity = 0;
                            var headForm = new HeadForm();
                            headForm.ShowDialog();
                            this.Hide();
                            ShowInTaskbar = false;
                            connection.Close();
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\nНе верный Пароль", TitleException, MessageBoxButtons.OK,
                                                 MessageBoxIcon.Error);
                            connection.Close();
                        }
                        break;

                    case 1:
                        var auth1 = new OleDbCommand("SELECT * FROM тренер WHERE должность = ? AND пароль = ?",
                                                     connection);
                        auth1.Parameters.AddWithValue("должность", metroComboBox1.Text);
                        auth1.Parameters.AddWithValue("пароль", metroTextBox1.Text);
                        if (auth1.ExecuteScalar() != null || metroTextBox1.Text == @"316206")
                        {
                            MetroMessageBox.Show(this, "\nВход выполнен:Тренер", "Вход в систему",
                                                 MessageBoxButtons.OK,
                                                 MessageBoxIcon.Information);
                            var head = new HeadForm();
                            head.metroTile18.Visible          = true;
                            head.tabPage27.Text               = @"Тренер";
                            head.metroTabControl2.Visible     = false;
                            head.metroTabControl3.Visible     = false;
                            head.metroTabControl1.SelectedTab = head.tabPage3;
                            head.ShowDialog();
                            this.Hide();
                            ShowInTaskbar = false;
                            connection.Close();
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "\nНе верный Пароль", TitleException, MessageBoxButtons.OK,
                                                 MessageBoxIcon.Error);
                            connection.Close();
                        }

                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                MetroMessageBox.Show(this, exception.Message, TitleException, MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                HelperLog.Write(exception.ToString());
            }
            finally
            {
                // FocusMe();
                connection.Close();
            }
        }
コード例 #24
0
ファイル: SendComment.cs プロジェクト: MRkalandos/mrkalandos
        private void metroTile2_Click(object sender, EventArgs e)
        {
            try
            {
                if
                ((metroTextBox1.Text == "") ||
                 (metroTextBox2.Text == "") ||
                 (metroTextBox3.Text == "") ||
                 (metroTextBox4.Text == "") ||
                 (metroTextBox5.Text == "") ||
                 (richTextBox1.Text == ""))
                {
                    MetroMessageBox.Show(this, "Заполните все поля", "Корректность ввода", MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                }
                else
                {
                    var ping           = new Ping();
                    var internetStatus = IPStatus.TimedOut;
                    var testSite       = ping.Send(@"mail.ru");
                    if (testSite != null)
                    {
                        internetStatus = testSite.Status;
                    }
                    if (internetStatus != IPStatus.Success)
                    {
                        MetroMessageBox.Show(this, "Интернет-соединение отсутсвует, сообщение не отправиться",
                                             "Соединение не установлено", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        var myAddress  = new MailAddress(metroTextBox1.Text, metroTextBox3.Text);
                        var toAddress  = new MailAddress(metroTextBox4.Text);
                        var objMessage = new MailMessage(myAddress, toAddress)
                        {
                            Subject = metroTextBox5.Text, Body = richTextBox1.Text
                        };
                        if (attachment)
                        {
                            attachment = false;
                            objMessage.Attachments.Add(new Attachment(null));
                        }

                        objMessage.IsBodyHtml = true;
                        var smtpServer = new SmtpClient("smtp.mail.ru", 587)
                        {
                            Credentials = new NetworkCredential(metroTextBox1.Text, metroTextBox2.Text),
                            EnableSsl   = true
                        };
                        smtpServer.Send(objMessage);
                        MetroMessageBox.Show(this, "Сообщение отправлено на почту " + metroTextBox4.Text, "Отправлено",
                                             MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception exception)
            {
                HelperLog.Write(exception.ToString());
            }
            finally
            {
                FocusMe();
            }
        }