Exemplo n.º 1
0
        private void ChoicePersonForm_Load(object sender, EventArgs e)
        {
            try
            {
                // инициализация таблицы персон (записи с анкетными данными)
                _personTable = PersonView2.CreatetTable();

                // инициализация биндинг сорса к таблице персон
                _personBS = new BindingSource();
                _personBS.CurrentChanged += new EventHandler(_personBS_CurrentChanged);
                _personBS.ListChanged    += new ListChangedEventHandler(_personBS_ListChanged);
                _personBS.DataSource      = _personTable;

                // присвоение источника вьюшке
                this.personView.AutoGenerateColumns = false;
                this.personView.DataSource          = _personBS;

                // инициализация Адаптера для считывания персон из БД
                string commandStr = PersonView2.GetSelectText(_org.idVal, _repYear);
                _personAdapter = new SQLiteDataAdapter(commandStr, _connection);
                // запосление таблицы данными с БД
                _personAdapter.Fill(_personTable);

                StajDohodForm.PersonId  = 0;
                allAnketsButton.Enabled = false;
                rawAnketsButton.Enabled = true;

                SQLiteConnection connection = new SQLiteConnection(_connection);
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                long countPensDocsInList  = Docs.CountDocsInList(_listId, DocTypes.GrantingPensionId, connection);
                long countOtherDocsInList = 0;
                countOtherDocsInList += Docs.CountDocsInList(_listId, DocTypes.InitialFormId, connection);
                countOtherDocsInList += Docs.CountDocsInList(_listId, DocTypes.CorrectionFormId, connection);
                countOtherDocsInList += Docs.CountDocsInList(_listId, DocTypes.CancelingFormId, connection);
                connection.Close();
                if (countPensDocsInList == 0 && countOtherDocsInList == 0)
                {
                    radioButton1.Enabled = true;
                    radioButton2.Enabled = true;
                    radioButton3.Enabled = true;
                    radioButton4.Enabled = true;

                    radioButton1.Checked = true;
                }
                else if (countPensDocsInList > 0 && countOtherDocsInList == 0)
                {
                    radioButton1.Enabled = false;
                    radioButton2.Enabled = false;
                    radioButton3.Enabled = false;
                    radioButton4.Enabled = true;

                    radioButton4.Checked = true;
                }
                else if (countPensDocsInList == 0 && countOtherDocsInList > 0)
                {
                    radioButton1.Enabled = true;
                    radioButton2.Enabled = true;
                    radioButton3.Enabled = true;
                    radioButton4.Enabled = false;

                    radioButton1.Checked = true;
                }
                else if (countPensDocsInList > 0 && countOtherDocsInList > 0)
                {
                    radioButton1.Enabled = false;
                    radioButton2.Enabled = false;
                    radioButton3.Enabled = false;
                    radioButton4.Enabled = false;

                    //radioButton1.Checked = true;
                }

                ToolTip toolTip1 = new ToolTip();
                toolTip1.SetToolTip(radioButton1,
                                    "Создается для застрахованного лица, на которое данные еще не передавались в фонд");
                toolTip1.SetToolTip(radioButton2,
                                    "Создается для застрахованного лица, если данные уже сданы в фонд и требуют корректировки");
                toolTip1.SetToolTip(radioButton3,
                                    "Создается для застрахованного лица, если данные уже сданы в фонд и их необходимо отменить (удалить)");
                toolTip1.SetToolTip(radioButton4,
                                    "Документы этого типа должны находиться в отдельном пакете и сдаются в бумажном виде");
            }
            catch (Exception ex)
            {
                MainForm.ShowErrorFlexMessage(ex.Message, "Ошибка заполнения формы");
                choiceButton.Enabled = false;
            }
        }