Example #1
0
        private void BtCommint_Click(object sender, EventArgs e)
        {
            switch (tbNewPassword.Text != tbConfPass.Text)
            {
            case (true):
                tbConfPass.Clear();
                tbNewPassword.Clear();
                break;

            case (false):
                DataBaseProcedure procedure = new DataBaseProcedure();
                DataBaseTables    tables    = new DataBaseTables();
                tables.qrAccess_rights += " and [Access_rights_name] = " +
                                          "'Студент'";
                tables.dtAccess_rightsFill();
                Int32 Access_Rights_id =
                    Convert.ToInt32(tables.dtAccess_rights.
                                    Rows[0][0].ToString());
                procedure.spProfile_New_User(tbNewLogin.Text,
                                             tbConfPass.Text, Access_Rights_id, 1,
                                             tbImagePath.Text);
                procedure.spStudent_Insert(tbNewLogin.Text,
                                           ((StudentsForm)parentCreate).tbStudentSurname.Text,
                                           ((StudentsForm)parentCreate).tbStudentName.Text,
                                           ((StudentsForm)parentCreate).tbStudentMiddleName.Text,
                                           ((StudentsForm)parentCreate).mtbTicketNumber.Text,
                                           Convert.ToInt32(((StudentsForm)parentCreate).
                                                           cbGroup.SelectedValue.ToString()));
                BtCancel_Click(sender, e);
                break;
            }
        }
        private void btStudentInsert_Click(object sender, EventArgs e)
        {
            switch (cbStudentLogin.Text == "" || tbStudentName.Text == "" ||
                    tbStudentSurname.Text == "" || tbStudentMiddleName.Text == "" ||
                    mtbTicketNumber.Text == "")
            {
            case (true):
                MessageBox.Show("Одно или несколько из полей не заполнены!");
                break;

            case (false):
                switch (btStudentInsert.Text)
                {
                case ("Добавить студента"):
                    DataBaseView view = new DataBaseView();
                    view.qrvProfiles_List += " where [Login_list] = '" + cbStudentLogin.Text + "' and [Status_list] = 'Студент'";
                    view.dtvProfiles_List();
                    try
                    {
                        procedure.spStudent_Insert(view.vdtProfiles_List.Rows[0][0].ToString(), tbStudentSurname.Text, tbStudentName.Text, tbStudentMiddleName.Text, mtbTicketNumber.Text, Convert.ToInt32(cbGroup.SelectedValue.ToString()));
                        cbStudentLogin.Items.Clear();
                        tbStudentMiddleName.Clear();
                        tbStudentName.Clear();
                        tbStudentSurname.Clear();
                        mtbTicketNumber.Clear();
                    }
                    catch
                    {
                        switch (MessageBox.Show("Данного студента нет в системе учётных записей! \n Создать новую учётную запись?", "Создание учётной записи", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                        case DialogResult.Yes:
                            DynamicObjects dynamic = new DynamicObjects();
                            dynamic.parentCreate = this;
                            Thread thread1 = new Thread(dynamic.NewStudentAccountCreate);
                            thread1.Start();
                            break;

                        case DialogResult.No:

                            break;
                        }
                    }
                    break;

                case ("Поменять учебную группу"):
                    DynamicObjects dynamicObjects = new DynamicObjects();
                    dynamicObjects.student = cbStudentLogin.Text;
                    dynamicObjects.parent  = this;
                    Thread thread = new Thread(dynamicObjects.ChangeFormCreate);
                    thread.Start();
                    break;
                }
                break;
            }
        }