Beispiel #1
0
        private void BackButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            MenuEmployee menuEmployee = new MenuEmployee();

            menuEmployee.ShowDialog();
        }
Beispiel #2
0
        private void AuthorizationButton_Click(object sender, EventArgs e)
        {
            connection = new SqlConnection(connectionString);

            try
            {
                connection.Open();

                dataAdapter = new SqlDataAdapter($"select [User].[Login], [User].[Password], [User].[Type_user], [User].[ID_user], [User].[Status_tenant] from dbo.[User] where [User].[Login] = '{LoginTextBox.Text}'", connection);
                DataSet ds = new DataSet();
                dataAdapter.Fill(ds);


                if (PasswordTextBox.Text == ds.Tables[0].Rows[0][1].ToString())
                {
                    if (ds.Tables[0].Rows[0][2].ToString() == "1")
                    {
                        ID           = ds.Tables[0].Rows[0][3].ToString();
                        StatusTenant = ds.Tables[0].Rows[0][4].ToString();
                        Type_user    = ds.Tables[0].Rows[0][2].ToString();

                        this.Hide();
                        MenuBuyer menuBuyer = new MenuBuyer(ID, StatusTenant, Type_user);
                        menuBuyer.Show();
                    }
                    if (ds.Tables[0].Rows[0][2].ToString() == "2")
                    {
                        ID           = ds.Tables[0].Rows[0][3].ToString();
                        StatusTenant = ds.Tables[0].Rows[0][4].ToString();
                        Type_user    = ds.Tables[0].Rows[0][2].ToString();

                        dataAdapter = new SqlDataAdapter($"select Time_CheckIn,Time_eviction from Contracts inner join Organiations on [User_ID] = '{ID}' where ID_contract = Contract_ID", connection);
                        DataSet Dates = new DataSet();
                        dataAdapter.Fill(Dates);

                        this.Hide();
                        if (Dates.Tables[0].Rows.Count > 0)
                        {
                            MenuOrganization menuOrganization = new MenuOrganization(ID, StatusTenant, Type_user, Dates.Tables[0].Rows[0][0].ToString(), Dates.Tables[0].Rows[0][1].ToString());
                            menuOrganization.Show();
                        }
                        else
                        {
                            MenuOrganization menuOrganization = new MenuOrganization(ID, StatusTenant, Type_user, "", "");
                            menuOrganization.Show();
                        }
                    }
                    if (ds.Tables[0].Rows[0][2].ToString() == "3")
                    {
                        this.Hide();
                        MenuEmployee menuEmployee = new MenuEmployee();
                        menuEmployee.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Неправильный пароль!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Неправильный логин!");
            }
            finally
            {
                connection.Close();
            }
        }