예제 #1
0
        //дополнительная инициализация контролов
        public override void InitControls()
        {
            InitFocusHandlers();
            _bdc = MainClass.Bdc;

            ComboServ.FillCombo(cbStudyLevelGroup, HelpClass.GetComboListByTable("ed.StudyLevelGroup", "ORDER BY Acronym"), false, false);
            ComboServ.FillCombo(cbStudyBasis, HelpClass.GetComboListByTable("ed.StudyBasis", "ORDER BY Name"), false, false);

            cbStudyBasis.SelectedIndex = 0;
            FillFaculty();
            FillStudyForm();
            FillLicenseProgram();

            UpdateDataGrid();

            cbStudyLevelGroup.SelectedIndexChanged += cbStudyLevel_SelectedIndexChanged;
            cbFaculty.SelectedIndexChanged         += new EventHandler(cbFaculty_SelectedIndexChanged);
            cbStudyForm.SelectedIndexChanged       += new EventHandler(cbStudyForm_SelectedIndexChanged);
            cbStudyBasis.SelectedIndexChanged      += new EventHandler(cbStudyBasis_SelectedIndexChanged);
            cbLicenseProgram.SelectedIndexChanged  += new EventHandler(cbLicenseProgram_SelectedIndexChanged);

            prh = new ProtocolRefreshHandler(UpdateDataGrid);
            MainClass.AddProtocolHandler(prh);
        }
예제 #2
0
        //обновление грида
        protected override void GetSource()
        {
            string sFilters = " WHERE HostelAbit = 1 ";

            int?facId = ComboServ.GetComboIdInt(cbFaculty);

            if (facId != null)
            {
                sFilters += string.Format(" AND HasAssignToHostel = 1 AND HostelFacultyId = {0}", facId);
            }


            _sQuery = @"SELECT ed.extPerson.Id, PersonNum as Ид_номер, FIO  as ФИО, 
            (Case When (CountryId = 1 AND NOT RegionId IS NULL) then RegionName else CountryName end) AS Место_жительства, 
            (Case when HostelFacultyId IS NULL then 'не выдано' else HostelFacultyName end) AS Факультет_выдавший_направление, 
            PassportData AS Паспортные_данные 
            FROM ed.qAbiturient INNER JOIN ed.extPerson ON ed.qAbiturient.PersonId = ed.extPerson.Id ";

            HelpClass.FillDataGrid(Dgv, _bdc, _sQuery, sFilters, " ORDER BY ФИО");

            dgvAbiturients.Columns[1].Width = 74;
            dgvAbiturients.Columns[2].Width = 234;
            dgvAbiturients.Columns[3].Width = 266;
        }
예제 #3
0
        public override void UpdateDataGrid()
        {
            if (StudyFormId == null || StudyBasisId == null)
            {
                dgvViews.DataSource = null;
                return;
            }
            string qquery = @"SELECT DISTINCT Id, Number + ' (' + CONVERT(nvarchar, Date, 104) + ')' AS 'Номер представления' 
FROM ed.extEntryView 
WHERE StudyFormId={0} AND StudyBasisId={1} " + (FacultyId.HasValue? "AND FacultyId= {2} ":"") + (LicenseProgramId.HasValue ? "AND LicenseProgramId = {3} ":"") + @"AND IsListener = {4} AND IsSecond = {5} 
AND IsReduced = {6} AND IsParallel = {7} AND IsForeign = {8} AND StudyLevelGroupId = {9}
order by 2";
            string query  = string.Format(qquery,
                                          StudyFormId,
                                          StudyBasisId,
                                          FacultyId,
                                          LicenseProgramId,
                                          QueryServ.StringParseFromBool(IsListener),
                                          QueryServ.StringParseFromBool(IsSecond),
                                          QueryServ.StringParseFromBool(IsReduced),
                                          QueryServ.StringParseFromBool(IsParallel),
                                          QueryServ.StringParseFromBool(MainClass.dbType == PriemType.PriemForeigners),
                                          StudyLevelGroupId);

            HelpClass.FillDataGrid(dgvViews, _bdc, query, "");

            if (dgvViews.Columns.Contains("Номер представления"))
            {
                dgvViews.Columns["Номер представления"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
            if (dgvViews.Rows.Count == 0)
            {
                dgvViews.CurrentCell = null;
                ViewProtocolInfo();
            }
        }
예제 #4
0
        //дополнительная инициализация контролов
        private void InitControls()
        {
            InitFocusHandlers();
            bdc = MainClass.Bdc;

            try
            {
                btnDeleteFromVed.Visible = btnDeleteFromVed.Enabled = false;
                btnUnload.Visible        = btnUnload.Enabled = false;

                //наверное нужно писать права по отдельным группам. Чуть больше, зато на порядок понятнее. И чтобы "левых" вставок не было
                //Паше наклейки печатать нельзя??? Непорядок!!!
                if (MainClass.IsFacMain())
                {
                    btnCreate.Visible = true;
                    btnChange.Visible = true;
                    btnDelete.Visible = false;

                    tbCountCell.Visible     = false;
                    lblCountCell.Visible    = false;
                    btnLock.Visible         = false;
                    btnCreateAdd.Visible    = true;
                    btnPrintSticker.Visible = false;
                }
                else if (MainClass.IsCryptoMain() || MainClass.IsPasha())
                {
                    btnCreate.Visible = false;
                    btnChange.Visible = false;
                    btnDelete.Visible = false;

                    tbCountCell.Visible     = true;
                    lblCountCell.Visible    = true;
                    btnLock.Visible         = true;
                    btnCreateAdd.Visible    = true;
                    btnPrintSticker.Visible = true;
                }
                else if (MainClass.IsPasha())
                {
                    btnDelete.Visible        = true;
                    btnChange.Visible        = true;
                    btnDeleteFromVed.Visible = btnDeleteFromVed.Enabled = true;
                    btnUnload.Visible        = btnUnload.Enabled = true;
                }
                else
                {
                    btnCreate.Visible = false;
                    btnChange.Visible = false;
                    btnDelete.Visible = false;

                    tbCountCell.Visible     = false;
                    lblCountCell.Visible    = false;
                    btnLock.Visible         = false;
                    btnCreateAdd.Visible    = false;
                    btnPrintSticker.Visible = false;
                }

                if (MainClass.IsOwner())
                {
                    btnCreate.Visible       = true;
                    btnChange.Visible       = true;
                    btnDelete.Visible       = true;
                    tbCountCell.Visible     = true;
                    lblCountCell.Visible    = true;
                    btnLock.Visible         = true;
                    btnCreateAdd.Visible    = true;
                    btnPrintSticker.Visible = true;
                }

                //по умолчанию печатается 2 штрих-кода
                tbCountCell.Text = (2).ToString();

                using (PriemEntities context = new PriemEntities())
                {
                    ComboServ.FillCombo(cbStudyLevelGroup, HelpClass.GetComboListByTable("ed.StudyLevelGroup", ""), false, false);
                    ComboServ.FillCombo(cbFaculty, HelpClass.GetComboListByTable("ed.qFaculty", "ORDER BY Acronym"), false, false);
                    ComboServ.FillCombo(cbStudyBasis, HelpClass.GetComboListByTable("ed.StudyBasis", "ORDER BY Name"), false, true);

                    UpdateVedList();
                    UpdateDataGrid();

                    cbFaculty.SelectedIndexChanged    += new EventHandler(cbFaculty_SelectedIndexChanged);
                    cbStudyBasis.SelectedIndexChanged += new EventHandler(cbStudyBasis_SelectedIndexChanged);
                    cbExamVed.SelectedIndexChanged    += new EventHandler(cbExamVed_SelectedIndexChanged);
                }
            }
            catch (Exception ex)
            {
                WinFormsServ.Error("Ошибка при инициализации формы ведомостей: " + ex.Message);
            }
        }
예제 #5
0
        //обновление грида
        public virtual void UpdateDataGrid()
        {
            //скрыли/показали кнопку, если надо
            if (ExamVedId == null)
            {
                btnChange.Enabled    = false;
                btnDelete.Enabled    = false;
                btnCreateAdd.Enabled = false;
                btnLock.Enabled      = false;

                lblLocked.Visible = false;

                tbCountCell.Enabled     = false;
                btnPrintSticker.Enabled = false;

                dgvList.DataSource = null;
                dgvList.Update();
                return;
            }
            else
            {
                if (cbExamVed.SelectedItem.ToString().Contains("дополнительная"))
                {
                    btnCreateAdd.Enabled = false;
                }
                else
                {
                    btnCreateAdd.Enabled = true;
                }

                using (PriemEntities context = new PriemEntities())
                {
                    bool isLocked = (from ev in context.extExamsVed
                                     where ev.Id == ExamVedId
                                     select ev.IsLocked).FirstOrDefault();
                    if (isLocked)
                    {
                        lblLocked.Visible       = true;
                        btnChange.Enabled       = false;
                        btnDelete.Enabled       = false;
                        btnLock.Enabled         = false;
                        btnPrintSticker.Enabled = true;
                        tbCountCell.Enabled     = true;
                    }
                    else
                    {
                        lblLocked.Visible       = false;
                        btnChange.Enabled       = true;
                        btnDelete.Enabled       = true;
                        btnLock.Enabled         = true;
                        btnPrintSticker.Enabled = false;
                        tbCountCell.Enabled     = false;
                    }
                }
            }

            //обработали номер
            string sFilters = string.Format("WHERE ed.ExamsVedHistory.ExamsVedId = '{0}' ", ExamVedId.ToString());

            if (!dgvList.Columns.Contains("Number"))
            {
                dgvList.Columns.Add("Number", "№");
                dgvList.Update();
            }
            dgvList.Columns["Number"].DisplayIndex = 0;

            HelpClass.FillDataGrid(dgvList, bdc, sQuery, sFilters, sOrderby);
        }
예제 #6
0
        //дополнительная инициализация
        protected virtual void InitControls()
        {
            this.MdiParent = MainClass.mainform;
            this.CenterToParent();
            InitFocusHandlers();

            Dgv = dgvRight;

            if (MainClass.IsPasha())
            {
                dtPassDate.Enabled = true;
            }
            else
            {
                dtPassDate.Enabled = false;
            }

            using (PriemEntities context = new PriemEntities())
            {
                tbExam.Text = (from vd in context.extExamInEntry
                               where vd.ExamId == examId
                               select vd.ExamName).FirstOrDefault();

                dtPassDate.Value = passDate;
                if (isAddVed)
                {
                    dtPassDate.Enabled = false;
                    lblAdd.Visible     = true;
                    if (addCount == 0)
                    {
                        lblAddCount.Text = "";
                    }
                    else
                    {
                        lblAddCount.Text = "(" + addCount + ")";
                    }
                }
                if (_Id == null)
                {
                    dtPassDate.Enabled = false;
                }

                if (studyBasisId == null)
                {
                    ComboServ.FillCombo(cbStudyBasis, HelpClass.GetComboListByTable("ed.StudyBasis", "ORDER BY Name"), false, true);
                }
                else
                {
                    ComboServ.FillCombo(cbStudyBasis, HelpClass.GetComboListByQuery(string.Format("SELECT CONVERT(varchar(100), Id) AS Id, Name FROM ed.StudyBasis WHERE Id = {0} ORDER BY Name", studyBasisId)), false, false);
                }

                ComboServ.FillCombo(cbStudyForm, HelpClass.GetComboListByQuery(string.Format("SELECT DISTINCT CONVERT(varchar(100), StudyFormId) AS Id, StudyFormName AS Name FROM ed.qEntry WHERE StudyLevelGroupId = {0} AND FacultyId = {1} ORDER BY Name", studyLevelGroupId, facultyId)), false, true);
                FillObrazProgram();

                //заполнение гридов
                FillGridLeft();
                UpdateRightGrid();

                cbStudyBasis.SelectedIndexChanged   += new EventHandler(cbStudyBasis_SelectedIndexChanged);
                cbStudyForm.SelectedIndexChanged    += new EventHandler(cbStudyForm_SelectedIndexChanged);
                cbObrazProgram.SelectedIndexChanged += new EventHandler(cbObrazProgram_SelectedIndexChanged);
            }
        }
예제 #7
0
        private void UpdateDataGrid()
        {
            using (PriemEntities context = new PriemEntities())
            {
                var query = from am in context.AttMarks
                            join sj in context.AttSubject
                            on am.AttSubjectId equals sj.Id
                            where am.PersonId == _personId
                            orderby sj.Name
                            select new
                {
                    am.Id,
                    Subject = sj.Name,
                    Mark    = am.Value
                };


                dgvExams.DataSource = query;

                dgvExams.Columns["Id"].Visible         = false;
                dgvExams.Columns["Subject"].HeaderText = "Предмет";
                dgvExams.Columns["Mark"].HeaderText    = "Оценка";

                if (!dgvExams.Columns.Contains("Delete"))
                {
                    DataGridViewButtonColumn col = new DataGridViewButtonColumn();
                    col.Name       = "Delete";
                    col.HeaderText = "Удалить оценку";
                    col.Text       = "Удалить";
                    col.UseColumnTextForButtonValue = true;

                    dgvExams.Columns.Add(col);
                    dgvExams.Update();
                }

                List <float> lAvg = new List <float>();
                //делаем проверочку
                _lMarks.Clear();
                foreach (DataGridViewRow row in dgvExams.Rows)
                {
                    _lMarks.Add(row.Cells["Subject"].Value.ToString());
                    lAvg.Add(float.Parse(row.Cells["Mark"].Value.ToString()));
                }

                float avg = 0;
                foreach (float i in lAvg)
                {
                    avg += i;
                }
                if (avg != 0 && lAvg.Count != 0)//division by zero, lol
                {
                    string avgstr = (avg / (float)lAvg.Count).ToString();
                    if (avgstr.Length >= 4)
                    {
                        tbAvg.Text = avgstr.Substring(0, 4);
                    }
                    else
                    {
                        tbAvg.Text = avgstr;
                    }
                }

                string filter = "";
                foreach (string s in _lMarks)
                {
                    filter += "'" + s + "'" + ", ";
                }
                if (filter.Length != 0)
                {
                    filter = filter.Substring(0, filter.Length - 2);
                    ComboServ.FillCombo(cbSubjects, HelpClass.GetComboListByQuery(string.Format("SELECT AttSubject.Name, Cast(AttSubject.Id as nvarchar(100)) FROM AttSubject WHERE AttSubject.Name NOT IN ({0})", filter)), true, false);
                }
                if (cbSubjects.SelectedIndex == -1)
                {
                    btnAdd.Enabled = false;
                }
                else
                {
                    btnAdd.Enabled = true;
                }
            }
        }
예제 #8
0
        public override void UpdateDataGrid()
        {
            try
            {
                string sOrderBy = string.Empty;
                if (MainClass.dbType == PriemType.PriemMag)
                {
                    sOrderBy = " ORDER BY comp , noexamssort, ed.extAbitMarksSum.TotalSum desc, preimsort desc, ed.qAbiturient.Coefficient, ed.extAbitMarksSum.TotalCount desc, ФИО";
                }
                else
                {
                    sOrderBy = " ORDER BY comp , noexamssort, ed.extAbitMarksSum.TotalSum desc, preimsort desc, DopOrProfSort desc, olymp, attestat, attAvg desc, ed.qAbiturient.Coefficient, ed.extAbitMarksSum.TotalCount desc, ФИО";
                }

                string totalQuery = null;
                iPlanValue = GetPlanValueAndCheckLock();

                if (chbFix.Checked)
                {
                    if (MainClass.dbType == PriemType.PriemMag)
                    {
                        _queryOrange = @", CASE WHEN EXISTS(SELECT PersonId FROM ed.hlpPersonsWithOriginals WHERE PersonId = ed.qAbiturient.PersonId AND EntryId <> ed.qAbiturient.EntryId) then 1 else 0 end as orange ";
                    }
                    else
                    {
                        _queryOrange = @", CASE WHEN EXISTS(SELECT ed.extEntryView.Id FROM ed.extEntryView INNER JOIN ed.Abiturient a ON ed.extEntryView.AbiturientId = a.Id WHERE a.PersonId = ed.qAbiturient.PersonId) then 1 else 0 end as orange ";
                    }

                    string queryFix = _queryBody + _queryOrange +
                                      @" FROM ed.qAbiturient                     
                    INNER JOIN ed.extPerson ON ed.extPerson.Id = ed.qAbiturient.PersonId                    
                    INNER JOIN ed.Competition ON ed.Competition.Id = ed.qAbiturient.CompetitionId 
                    INNER JOIN ed.Fixieren ON ed.Fixieren.AbiturientId=ed.qAbiturient.Id 
                    LEFT JOIN ed.hlpEntryWithAddExams ON hlpEntryWithAddExams.EntryId = qAbiturient.EntryId
                    LEFT JOIN ed.FixierenView ON ed.Fixieren.FixierenViewId=ed.FixierenView.Id 
                    LEFT JOIN ed.hlpAbiturientProfAdd ON ed.hlpAbiturientProfAdd.Id = ed.qAbiturient.Id 
                    LEFT JOIN ed.hlpAbiturientProf ON ed.hlpAbiturientProf.Id = ed.qAbiturient.Id 
                    LEFT JOIN ed.extAbitMarksSum ON ed.qAbiturient.Id = ed.extAbitMarksSum.Id";

                    string whereFix = string.Format(@" WHERE ed.FixierenView.StudyLevelGroupId = {10} AND ed.FixierenView.StudyFormId={0} AND ed.FixierenView.StudyBasisId={1} AND ed.FixierenView.FacultyId={2} 
                                                    AND ed.FixierenView.LicenseProgramId={3} AND ed.FixierenView.ObrazProgramId={4} {5} AND ed.FixierenView.IsCel = {6}
                                                    AND ed.FixierenView.IsSecond = {7} AND ed.FixierenView.IsReduced = {8} AND ed.FixierenView.IsParallel = {9} ",
                                                    StudyFormId, StudyBasisId, FacultyId, LicenseProgramId, ObrazProgramId, ProfileId == null ? " AND ed.FixierenView.ProfileId IS NULL" : "AND ed.FixierenView.ProfileId='" + ProfileId + "'",
                                                    QueryServ.StringParseFromBool(false), QueryServ.StringParseFromBool(IsSecond), QueryServ.StringParseFromBool(IsReduced), QueryServ.StringParseFromBool(IsParallel), StudyLevelGroupId);

                    totalQuery = queryFix + whereFix + sOrderBy;
                }
                else
                {
                    string sFilters = GetFilterString();

                    //не забрали доки
                    sFilters += " AND (ed.qAbiturient.BackDoc=0) ";
                    sFilters += " AND ed.qAbiturient.Id NOT IN (select abiturientid from ed.extentryview) ";

                    // кроме бэ преодолены мин планки
                    sFilters += " AND ((CompetitionId=1  OR CompetitionId=8) OR hlpMinMarkAbiturient.Id IS NULL )";

                    string examsCnt = _bdc.GetStringValue(string.Format(" SELECT Count(Id) FROM ed.extExamInEntry WHERE EntryId='{0}' ", EntryId.ToString()));

                    if (MainClass.dbType == PriemType.PriemMag)
                    {
                        _queryOrange = @", CASE WHEN EXISTS(SELECT PersonId FROM ed.hlpPersonsWithOriginals WHERE PersonId = ed.qAbiturient.PersonId AND EntryId <> ed.qAbiturient.EntryId) then 1 else 0 end as orange ";

                        // кроме бэ нужное кол-во оценок есть
                        sFilters += " AND ((CompetitionId=1  OR CompetitionId=8) OR ed.extAbitMarksSum.TotalCount = " + examsCnt + " ) ";

                        totalQuery = _queryBody + _queryOrange + _queryFrom + sFilters + sOrderBy;
                    }
                    else
                    {
                        _queryOrange = @", CASE WHEN EXISTS(SELECT ed.extEntryView.Id FROM ed.extEntryView INNER JOIN ed.Abiturient a ON ed.extEntryView.AbiturientId = a.Id WHERE a.PersonId = ed.qAbiturient.PersonId) then 1 else 0 end as orange ";

                        //if(StudyBasisId == 1)
                        //    sFilters += " AND qAbiturient.Id NOT IN (SELECT AbiturientId FROM ed._FirstWaveGreenBackUp2)";

                        sFilters += " AND ed.qAbiturient.CompetitionId NOT IN (6, 1, 2, 7) ";

                        // кроме бэ и тех, у кого нет сертификатов и оценок нужное кол-во оценок есть
                        sFilters += @" AND ((CompetitionId=1  OR CompetitionId=8) 
                                        OR (ed.qAbiturient.PersonId NOT IN (SELECT PersonId FROM ed.EgeCertificate) 
                                           AND ed.qAbiturient.Id NOT IN (SELECT abiturientid from ed.Mark where IsFromEge = 1) and ed.extPerson.EgeInSPbgu = 0 and ed.qAbiturient.IsSecond = 0 and ed.qAbiturient.IsReduced = 0 and ed.qAbiturient.IsParallel = 0) 
                                        OR ed.extAbitMarksSum.TotalCount = " + examsCnt + " ) ";

                        totalQuery = _queryBody + _queryOrange + _queryFrom + sFilters + sOrderBy;
                    }
                }

                if (!dgvAbits.Columns.Contains("Number"))
                {
                    dgvAbits.Columns.Add("Number", "№ п/п");
                }

                HelpClass.FillDataGrid(dgvAbits, _bdc, totalQuery, "");

                dgvAbits.Columns["Id"].Visible            = false;
                dgvAbits.Columns["comp"].Visible          = false;
                dgvAbits.Columns["noexamssort"].Visible   = false;
                dgvAbits.Columns["preimsort"].Visible     = false;
                dgvAbits.Columns["olymp"].Visible         = false;
                dgvAbits.Columns["attestat"].Visible      = false;
                dgvAbits.Columns["attAvg"].Visible        = false;
                dgvAbits.Columns["DopOrProfSort"].Visible = false;
                dgvAbits.Columns["orange"].Visible        = false;

                if (MainClass.dbType == PriemType.PriemMag)
                {
                    dgvAbits.Columns["Серия аттестата"].Visible = false;
                    dgvAbits.Columns["Медалист"].HeaderText     = "Красный диплом";
                }
                else
                {
                    dgvAbits.Columns["Серия диплома"].Visible = false;
                }

                foreach (DataGridViewColumn column in dgvAbits.Columns)
                {
                    column.SortMode = DataGridViewColumnSortMode.NotSortable;
                }

                lblCount.Text = dgvAbits.RowCount.ToString() + "             Cвободных мест: " + iPlanValue;
            }
            catch (Exception ex)
            {
                WinFormsServ.Error("Ошибка при обновлении списка.", ex);
            }
        }
예제 #9
0
 private void ListPerson_Activated(object sender, EventArgs e)
 {
     HelpClass.FillDataGrid(dgvAbitList, _bdc, MainClass.qBuilder.GetQuery(MainClass._config.ColumnListPerson, "ed.Person"), "");
     lblCount.Text = dgvAbitList.RowCount.ToString();
 }
예제 #10
0
        private void DoUpdate(string filters, string orderby, List <string> tableList)
        {
            List <string> lTables = tableList == null ? new List <string>() : tableList;

            if (_list != null)
            {
                foreach (iFilter i in _list)
                {
                    if (i is Filter)
                    {
                        string sTable = (i as Filter).GetFilterItem().Table;
                        if (!lTables.Contains(sTable))
                        {
                            lTables.Add(sTable);
                        }
                    }
                }
            }

            if (!MainClass._config.ColumnListAbit.Contains("Рег_номер"))
            {
                MainClass._config.ColumnListAbit.Add("Рег_номер");
            }
            if (!MainClass._config.ColumnListAbit.Contains("ФИО"))
            {
                MainClass._config.ColumnListAbit.Add("ФИО");
            }


            string            sortedColumn = string.Empty;
            ListSortDirection order        = ListSortDirection.Ascending;
            bool sorted = false;
            int  index  = dgvAbitList.CurrentRow == null ? -1 : dgvAbitList.CurrentRow.Index;

            if (dgvAbitList.SortOrder != SortOrder.None)
            {
                sorted       = true;
                sortedColumn = dgvAbitList.SortedColumn.Name;
                order        = dgvAbitList.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending;
            }
            HelpClass.FillDataGrid(this.dgvAbitList, this._bdc, MainClass.qBuilder.GetQuery(MainClass._config.ColumnListAbit, lTables, null), filters, orderby);

            if (_groupList == null)
            {
                try
                {
                    if (dgvAbitList.Rows.Count > 0)
                    {
                        if (sorted && dgvAbitList.Columns.Contains(sortedColumn))
                        {
                            dgvAbitList.Sort(dgvAbitList.Columns[sortedColumn], order);
                        }
                        if (index >= 0 && index <= dgvAbitList.Rows.Count)
                        {
                            dgvAbitList.CurrentCell = dgvAbitList[1, index];
                        }
                    }
                }
                catch
                {
                }
            }
            else
            {
                _groupList = null;
            }

            lblCount.Text   = dgvAbitList.RowCount.ToString();
            btnCard.Enabled = (dgvAbitList.RowCount != 0);
        }
예제 #11
0
        //обновление грида
        public void UpdateDataGridAbits()
        {
            try
            {
                int?changeTp = ChangeTypeId;

                string abitQuery     = string.Format("SELECT Barcode, (Case When BackDoc = 1 then 1 else 0 end) AS BackDoc, Cast(Priority AS nvarchar(10)) AS Priority FROM ed.extAbit WHERE Barcode > 0  {0} ", GetFilterString("ed.extAbit"));
                string abitQueryInet = string.Format("SELECT qAbiturient.Barcode, Cast(qAbiturient.Priority AS nvarchar(10)) AS Priority, (Case When qAbiturient.Enabled = 1 then 0 else 1 end) AS BackDoc FROM qAbiturient WHERE  IsImported = 1 AND Barcode > 0 {0} ", GetFilterString("qAbiturient"));

                Dictionary <int, ChangeAbitClass> abits;
                Dictionary <int, ChangeAbitClass> abitsInet;

                lstAbits = new Dictionary <int, ChangeAbitClass>();

                switch (changeTp)
                {
                // приоритеты
                case 1:
                {
                    abitQuery     += " AND BackDoc = 0 ";
                    abitQueryInet += " AND Enabled = 1 AND NOT Priority IS NULL ";

                    abits     = GetAbitList(_bdc.GetDataSet(abitQuery));
                    abitsInet = GetAbitList(_bdcInet.GetDataSet(abitQueryInet));

                    if (abitsInet.Count == 0)
                    {
                        SetNullGrid();
                        return;
                    }

                    foreach (ChangeAbitClass cl in abits.Values)
                    {
                        if (!abitsInet.Keys.Contains(cl.Barcode))
                        {
                            continue;
                        }

                        ChangeAbitClass inAb = abitsInet[cl.Barcode];

                        if (cl.Priority != inAb.Priority)
                        {
                            lstAbits.Add(cl.Barcode, new ChangeAbitClass(cl.Barcode, inAb.Priority, cl.BackDoc));
                        }
                    }

                    break;
                }

                // забрал документы в инете
                case 2:
                {
                    abitQuery     += " AND BackDoc = 0 ";
                    abitQueryInet += " AND Enabled = 0 ";

                    abits     = GetAbitList(_bdc.GetDataSet(abitQuery));
                    abitsInet = GetAbitList(_bdcInet.GetDataSet(abitQueryInet));

                    if (abitsInet.Count == 0)
                    {
                        SetNullGrid();
                        return;
                    }

                    foreach (ChangeAbitClass cl in abits.Values)
                    {
                        if (!abitsInet.Keys.Contains(cl.Barcode))
                        {
                            continue;
                        }

                        ChangeAbitClass inAb = abitsInet[cl.Barcode];

                        if (!cl.BackDoc && inAb.BackDoc)
                        {
                            lstAbits.Add(cl.Barcode, new ChangeAbitClass(cl.Barcode, cl.Priority, inAb.BackDoc));
                        }
                    }

                    break;
                }

                // забрал документы в нашей базе
                case 3:
                {
                    abitQuery     += " AND BackDoc = 1 ";
                    abitQueryInet += " AND Enabled = 1 ";

                    abits     = GetAbitList(_bdc.GetDataSet(abitQuery));
                    abitsInet = GetAbitList(_bdcInet.GetDataSet(abitQueryInet));

                    if (abitsInet.Count == 0)
                    {
                        SetNullGrid();
                        return;
                    }

                    foreach (ChangeAbitClass cl in abits.Values)
                    {
                        if (!abitsInet.Keys.Contains(cl.Barcode))
                        {
                            continue;
                        }

                        ChangeAbitClass inAb = abitsInet[cl.Barcode];

                        if (cl.BackDoc && !inAb.BackDoc)
                        {
                            lstAbits.Add(cl.Barcode, new ChangeAbitClass(cl.Barcode, cl.Priority, cl.BackDoc));
                        }
                    }

                    break;
                }
                }

                if (lstAbits.Count == 0)
                {
                    SetNullGrid();
                    return;
                }

                string query = string.Format(
                    @"SELECT ed.extAbit.Id, Person.Surname + ' ' + Person.Name + ' ' + Person.SecondName as ФИО, 
                   Person.BirthDate AS Дата_рождения, ed.extAbit.Barcode, Person.Barcode AS PersonBarcode,
                   ed.extAbit.FacultyName as Факультет, ed.extAbit.LicenseProgramName AS Направление, ed.extAbit.ObrazProgramName AS Образ_программа, 
                   ed.extAbit.ProfileName AS Профиль, ed.extAbit.StudyBasisName AS Основа 
                   FROM ed.extAbit INNER JOIN ed.Person ON ed.extAbit.PersonId = Person.Id 
                   WHERE 1=1 {0} AND ed.extAbit.Barcode IN({1}) ORDER BY ФИО", GetFilterString("ed.extAbit"), GetListKeys(lstAbits));


                HelpClass.FillDataGrid(dgvAbiturients, _bdc, query, "");
                dgvAbiturients.Columns["Barcode"].Visible       = false;
                dgvAbiturients.Columns["PersonBarcode"].Visible = false;
                lblCount.Text = "Всего: " + dgvAbiturients.RowCount.ToString();
            }
            catch (Exception exc)
            {
                WinFormsServ.Error(exc.Message);
            }

            btnLoad.Enabled = !(dgvAbiturients.RowCount == 0);
        }