예제 #1
0
 private void Back_button_Click(object sender, EventArgs e)
 {
     if (AvtorisForm.name == "Kladovshic")
     {
         this.Hide();//скрывает окно
         KladovshicForm usForm = new KladovshicForm();
         usForm.Show();
     }
     if (AvtorisForm.name == "Direcktor")
     {
         this.Hide();
         DirektorForm usForm = new DirektorForm();
         usForm.Show();
     }
     if (AvtorisForm.name == "Menedger")
     {
         this.Hide();
         MenedgerForm usForm = new MenedgerForm();
         usForm.Show();
     }
     if (AvtorisForm.name == "user")
     {
         this.Hide();
         ZakazchicForm usForm = new ZakazchicForm();
         usForm.Show();
     }
 }
예제 #2
0
        private void buttonReg_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection sqlConnect = new SqlConnection("Data Source=LAPTOP-562FH47J\\SQL2017;Initial Catalog=Fabrica;Integrated Security=True");
                sqlConnect.Open();
                SqlCommand queryInsert = new SqlCommand("INSERT INTO [dbo].[Polsovatel] (Login, Password, Pol, Naimenovenie)" +
                                                        "VALUES ('" + textLogin.Text + "','" + textPassword.Text + "','user','" + textInitials.Text + "')", sqlConnect);

                if (!string.IsNullOrEmpty(textLogin.Text) && !string.IsNullOrWhiteSpace(textLogin.Text) &&
                    !string.IsNullOrEmpty(textPassword.Text) && !string.IsNullOrWhiteSpace(textPassword.Text)
                    )
                {
                    queryInsert.ExecuteNonQuery();
                    sqlConnect.Close();
                    MessageBox.Show("Вы создали пользователя!");
                    this.Hide(); //cкрывает текущее окно
                    ZakazchicForm regForm = new ZakazchicForm();
                    regForm.Show();
                }
                else
                {
                    MessageBox.Show("Все обязательные поля не заполнены. Пользователь не создан!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Пользователь с таким логином существует в системе.", ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #3
0
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            SqlConnection sqlConnect = new SqlConnection("Data Source=LAPTOP-562FH47J\\SQL2017;Initial Catalog=Fabrica;Integrated Security=True"); //Подключение к серверу БД

            sqlConnect.Open();
            SqlCommand sqlQuery = new SqlCommand("SELECT * FROM [dbo].[Polsovatel]" +
                                                 "WHERE Login = '******' AND " +
                                                 "Password = '******'", sqlConnect); // запрос в таблицу "Polsovatel"
            SqlDataReader sqlReader = null;

            sqlReader = sqlQuery.ExecuteReader();
            if (sqlReader.HasRows)
            {
                sqlReader.Read();

                if ((sqlReader.GetValue(0).ToString() == textLogin.Text) &&
                    (sqlReader.GetValue(1).ToString() == textPassword.Text))
                {
                    if (sqlReader.GetValue(2).ToString() == "Kladovshic")
                    {
                        name = "Kladovshic";
                        this.Hide();//скрывает окно
                        KladovshicForm usForm = new KladovshicForm();
                        usForm.Show();
                    }
                    if (sqlReader.GetValue(2).ToString() == "Direcktor")
                    {
                        name = "Direcktor";
                        this.Hide();
                        DirektorForm usForm = new DirektorForm();
                        usForm.Show();
                    }
                    if (sqlReader.GetValue(2).ToString() == "Menedger")
                    {
                        name = "Menedger";
                        this.Hide();
                        MenedgerForm usForm = new MenedgerForm();
                        usForm.Show();
                    }
                    if (sqlReader.GetValue(2).ToString() == "user")
                    {
                        name = "user";
                        this.Hide();
                        ZakazchicForm usForm = new ZakazchicForm();
                        usForm.Show();
                    }
                }
            }
            else
            {
                MessageBox.Show("Такого пользователя не существует. Пересоздайте или введи заново.");
            }
        }
예제 #4
0
 private void LoginOut_button_Click(object sender, EventArgs e)
 {
     if (AvtorisForm.name == "Director")
     {
         this.Hide();
         DirektorForm DirForm = new DirektorForm();
         DirForm.Show();
     }
     if (AvtorisForm.name == "Menedger")
     {
         this.Hide();
         MenedgerForm usForm = new MenedgerForm();
         usForm.Show();
     }
     if (AvtorisForm.name == "user")
     {
         this.Hide();
         ZakazchicForm Zfr = new ZakazchicForm();
         Zfr.Show();
     }
 }