Exemplo n.º 1
0
        private void BtEnter_Click(object sender, EventArgs e)
        {
            int acces = 0;

            switch (((BurdenCombinationEmployeeForm)parentCheck).OldRole
                    == Convert.ToInt32(((BurdenCombinationEmployeeForm)parentCheck).
                                       cbAccessRights.SelectedValue.ToString()))
            {
            case (true):
                acces = 1;
                break;

            case (false):
                acces = 0;
                break;
            }
            switch (((BurdenCombinationEmployeeForm)parentCheck).OldPassword
                    == tbOldPassword.Text)
            {
            case (true):
                DataBaseProcedure procedure = new DataBaseProcedure();
                procedure.spProfile_Update_User(
                    ((BurdenCombinationEmployeeForm)parentCheck).cbLogin.Text,
                    tbOldPassword.Text,
                    Convert.ToInt32(((BurdenCombinationEmployeeForm)parentCheck).
                                    cbAccessRights.SelectedValue.ToString()),
                    acces, ((BurdenCombinationEmployeeForm)parentCheck).
                    tbImagePath.Text);
                procedure.spEmployee_Update(((BurdenCombinationEmployeeForm)parentCheck)
                                            .cbLogin.Text,
                                            ((BurdenCombinationEmployeeForm)parentCheck).tbSurName.Text,
                                            ((BurdenCombinationEmployeeForm)parentCheck).tbName.Text,
                                            ((BurdenCombinationEmployeeForm)parentCheck).tbMiddleName.Text);
                BtCancelCoferm_Click(sender, e);
                break;

            case (false):
                tbConfPass.Clear();
                break;
            }
        }
        private void btInsertUpdate_Click(object sender, EventArgs e)
        {
            switch (tbPassword.Text != tbConfPass.Text)
            {
            case (true):
                tbPassword.Clear();
                tbConfPass.Clear();
                Registry_Class.error_message += "\n" + DateTime.Now.ToLongDateString() + " пароли не совпадают!";
                btError_Click(sender, e);
                break;

            case (false):
                switch (EmployeeCount)
                {
                case (0):
                    switch (MessageBox.Show(
                                "Создать ноую учётную запись:" +
                                "\n Логин: " + cbLogin.Text + "," +
                                "\n Права доступа: " + cbAccessRights.Text + "," +
                                "\n Персональные данные:" +
                                "\n Фамилия: " + tbSurName.Text + "," +
                                "\n Имя:" + tbName.Text + "," +
                                "\n Отчество: " + tbMiddleName.Text + ".", "Создание нового сотрудника",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question))
                    {
                    case DialogResult.Yes:
                        DataBaseProcedure procedure = new DataBaseProcedure();
                        procedure.spProfile_New_User(cbLogin.Text, tbPassword.Text, Convert.ToInt32(cbAccessRights.SelectedValue.ToString()), 0, tbImagePath.Text);
                        cbLogin.Text = "";
                        tbPassword.Clear();
                        tbConfPass.Clear();
                        tbSurName.Clear();
                        tbName.Clear();
                        tbMiddleName.Clear();
                        tbImagePath.Clear();
                        break;
                    }
                    break;

                default:
                    switch (OldPassword == tbPassword.Text)
                    {
                    case (true):
                        int access = 0;
                        switch (OldRole == Convert.ToInt32(cbAccessRights.SelectedValue.ToString()))
                        {
                        case (true):
                            access = 1;
                            break;

                        case (false):
                            access = 0;
                            break;
                        }
                        DataBaseProcedure procedure = new DataBaseProcedure();
                        procedure.spProfile_Update_User(cbLogin.Text, tbPassword.Text,
                                                        Convert.ToInt32(cbAccessRights.SelectedValue.ToString()), access, tbImagePath.Text);
                        procedure.spEmployee_Update(cbLogin.Text, tbSurName.Text,
                                                    tbName.Text, tbMiddleName.Text);
                        break;

                    case (false):
                        DynamicObjects dynamicObjects = new DynamicObjects();
                        dynamicObjects.parentCheck = this;
                        dynamicObjects.createCheckPass();
                        break;
                    }
                    break;
                }
                break;
            }
        }