Ejemplo n.º 1
0
        private void btCancel_Click(object sender, RoutedEventArgs e)
        {
            KladovchikWindow k = new KladovchikWindow();

            k.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            String connectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

            con = new OracleConnection(connectionString);

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                OracleCommand cmd = con.CreateCommand();
                cmd.BindByName  = true;
                cmd.CommandText = "SELECT COUNT(1) FROM ПОЛЬЗОВАТЕЛЬ WHERE ЛОГИН=:ЛОГИН AND ПАРОЛЬ=:ПАРОЛЬ AND РОЛЬ=:РОЛЬ";
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("ЛОГИН", OracleDbType.Varchar2, 150).Value  = txtUsername.Text;
                cmd.Parameters.Add("ПАРОЛЬ", OracleDbType.Varchar2, 150).Value = txtPassword.Password;
                cmd.Parameters.Add("РОЛЬ", OracleDbType.Varchar2, 150).Value   = FunctionCBox.SelectedItem.ToString();
                int count = Convert.ToInt32(cmd.ExecuteScalar());
                if (count == 1)
                {
                    if (FunctionCBox.SelectedItem.ToString() == "Дирекция")
                    {
                        DirekciaWindow d = new DirekciaWindow(txtUsername.Text);
                        d.Show();
                        this.Close();
                    }
                    else if (FunctionCBox.SelectedItem.ToString() == "Заказчик")
                    {
                        ZakazWindow z = new ZakazWindow(txtUsername.Text);
                        z.Show();
                        this.Close();
                    }
                    else if (FunctionCBox.SelectedItem.ToString() == "Менеджер")
                    {
                        MainWindow main = new MainWindow(txtUsername.Text);
                        main.Show();
                        this.Close();
                    }
                    else
                    {
                        KladovchikWindow k = new KladovchikWindow(txtUsername.Text);
                        k.Show();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Логин, пароль или роль не правилно");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Пожалуйста запольняйте все поли");
            }
            finally
            {
                con.Close();
            }
        }