Ejemplo n.º 1
0
        private void btn_create_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dgv_prifiles.Rows.Count; i++)
            {
                if (dgv_prifiles[0, i].Value == null)
                {
                    CreateApplication(_addTask);
                    _addTask.Clear();
                    MessageBox.Show("Заявка создана!", "Зявка создана");
                    ChiefWorm chiefworm = new ChiefWorm(_userID);
                    chiefworm.Show();
                    status = false;
                    this.Close();
                    return;
                }

                if (_addTask.ContainsKey(dgv_prifiles[0, i].Value.ToString()))
                {
                    var exists = Convert.ToInt32(_addTask[dgv_prifiles[0, i].Value.ToString()]);
                    _addTask[dgv_prifiles[0, i].Value.ToString()] = Convert.ToInt32(dgv_prifiles[1, i].Value) + exists;
                    continue;
                }

                _addTask.Add(dgv_prifiles[0, i].Value.ToString(), Convert.ToInt32(dgv_prifiles[1, i].Value));
            }
        }
Ejemplo n.º 2
0
        private void btn_logIn_Click(object sender, EventArgs e)
        {
            if (Authentications.AuthCheckLogIn(tb_userLogin.Text, tb_password.Text))
            {
                int    userRoleId;
                int    userID;
                string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand($"Select Role_id From Users Where Login = '******'", connection);
                    userRoleId = Convert.ToInt32(command.ExecuteScalar());

                    command = new SqlCommand($"Select User_id From Users Where Login = '******'", connection);
                    userID  = Convert.ToInt32(command.ExecuteScalar());
                }

                if (userRoleId == 1)
                {
                    btn17 = true;
                    ChiefWorm chiefWorm = new ChiefWorm(userID);
                    chiefWorm.Show();
                    Close();
                }

                if (userRoleId == 2)
                {
                    btn17 = true;
                    WorkersForm worker1Form = new WorkersForm(userID, new FirstWorkerQuery());
                    worker1Form.Show();
                    Close();
                }
                if (userRoleId == 3)
                {
                    btn17 = true;
                    WorkersForm worker1Form = new WorkersForm(userID, new SecondWorkerQuery());
                    worker1Form.Show();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Неверное имя или пароль.", "Ошибка входа");
            }
        }