예제 #1
0
        public DocsClass(int personBarcode, int?abitCommitBarcode)
        {
            _bdcInet      = new DBPriem();
            _bdcInetFiles = new DBPriem();
            try
            {
                _bdcInet.OpenDatabase(MainClass.connStringOnline);
                _bdcInetFiles.OpenDatabase(MainClass.connStringOnlineFiles);
            }
            catch (Exception exc)
            {
                WinFormsServ.Error(exc.Message);
            }

            _personId = _bdcInet.GetStringValue("SELECT Person.Id FROM Person WHERE Person.Barcode = " + personBarcode);

            if (abitCommitBarcode == null)
            {
                _abitId = null;
            }
            else
            {
                _abitId   = _bdcInet.GetStringValue("SELECT qAbiturient.Id FROM qAbiturient WHERE qAbiturient.CommitNumber = " + abitCommitBarcode);
                _commitId = _bdcInet.GetStringValue("SELECT qAbiturient.CommitId FROM qAbiturient WHERE qAbiturient.CommitNumber = " + abitCommitBarcode);
            }
        }
예제 #2
0
        //дополнительная инициализация
        protected virtual void InitControls()
        {
            this.CenterToParent();
            InitFocusHandlers();

            Dgv = dgvRight;

            tbExam.Text = bdc.GetStringValue(string.Format("SELECT DISTINCT ExamName FROM ed.extExamInEntry WHERE ExamId = '{0}'", examId));
            tbDate.Text = passDate.ToShortDateString();


            //заполнение гридов
            InitGrid(dgvLeft);
            FillGridRight();
        }
예제 #3
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                using (PriemEntities context = new PriemEntities())
                {
                    int marksCount = 0;

                    SortedList <string, string> slAbitsWithMark = new SortedList <string, string>();

                    string flt = "";
                    flt += " AND ed.qAbiturient.BackDoc = 0 ";
                    flt += " AND ed.qAbiturient.NotEnabled = 0 ";
                    flt += " AND ed.qAbiturient.Id IN (SELECT AbiturientId FROM ed.extProtocol WHERE ProtocolTypeId = 1 AND IsOld = 0 AND Excluded = 0) ";
                    flt += " AND ed.qAbiturient.StudyLevelGroupId = " + MainClass.studyLevelGroupId;
                    flt += string.Format(" AND ed.qAbiturient.EntryId IN (SELECT EntryId FROM ed.extExamInEntry WHERE ExamId = {0})", _examId);

                    string flt_fac = "";
                    if (_isAdditional)
                    {
                        flt_fac = " AND FacultyId = " + _facultyId;
                    }

                    foreach (DataGridViewRow dgvr in dgvMarks.Rows)
                    {
                        string val = dgvr.Cells["Баллы"].Value.ToString();
                        if (dgvr.Cells["Баллы"].Value == null || val.CompareTo("") == 0)
                        {
                            continue;
                        }

                        string perId = dgvr.Cells["PersonId"].Value.ToString();

                        if (_studybasisId == "2")
                        {
                            DataSet dsAbit = bdc.GetDataSet(string.Format(@"SELECT ed.qAbiturient.Id, ed.qMark.Value FROM ed.qAbiturient 
                                LEFT JOIN (ed.qMark INNER JOIN ed.extExamInEntry ON ed.qMark.ExamInEntryId = ed.extExamInEntry.Id) 
                                ON ed.qMark.AbiturientId = ed.qAbiturient.Id AND ed.extExamInEntry.ExamId = {1} 
                                WHERE ed.qAbiturient.PersonId = '{0}' AND ed.qAbiturient.StudyBasisId = 2 {2} {3}", perId, _examId, flt, flt_fac));

                            foreach (DataRow dra in dsAbit.Tables[0].Rows)
                            {
                                if (dra["Value"] == null || dra["Value"].ToString() == "")
                                {
                                    slNewMark.Add(dra["Id"].ToString(), val);
                                }
                                else
                                {
                                    slAbitsWithMark.Add(dra["Id"].ToString(), val);
                                }
                            }
                        }
                        else
                        {
                            DataSet ds = bdc.GetDataSet(string.Format("SELECT ed.qAbiturient.Id FROM ed.qAbiturient WHERE PersonId = '{0}' {1} {2} {3}", perId, flt_fac, _studybasisId == "" ? "" : " AND qAbiturient.StudyBasisId = " + _studybasisId, flt));
                            foreach (DataRow row in ds.Tables[0].Rows)
                            {
                                if (int.Parse(bdc.GetStringValue(string.Format("SELECT Count(ed.qMark.Id) FROM ed.qMark INNER JOIN ed.extExamInEntry ON ed.qMark.ExamInEntryId = ed.extExamInEntry.Id WHERE ed.extExamInEntry.ExamId = '{0}' AND AbiturientId = '{1}'", _examId, row["Id"].ToString()))) > 0)
                                {
                                    continue;
                                }

                                slNewMark.Add(row["Id"].ToString(), val);
                            }
                        }
                    }

                    if (slAbitsWithMark.Count > 0)
                    {
                        SetNewMark frm = new SetNewMark(this, _examId, _dateExam, slAbitsWithMark);
                        frm.ShowDialog();
                    }

                    //using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew))
                    //{
                    foreach (string abId in slNewMark.Keys)
                    {
                        DataSet dss = bdc.GetDataSet(string.Format("SELECT Id, EntryId FROM ed.qAbiturient WHERE Id = '{0}' ", abId));
                        DataRow drr = dss.Tables[0].Rows[0];

                        string examInPr = Exams.GetExamInEntryId(_examId, drr["EntryId"].ToString());

                        Guid abitId        = new Guid(abId);
                        int  examInEntryId = int.Parse(examInPr);
                        int  val           = int.Parse(slNewMark[abId]);

                        int cnt = (from mrk in context.qMark
                                   where mrk.ExamInEntryId == examInEntryId && mrk.AbiturientId == abitId
                                   select mrk).Count();

                        if (cnt > 0)
                        {
                            continue;
                        }

                        List <string> list = Exams.GetExamIdsInEntry(drr["EntryId"].ToString());

                        if (list.Contains(_examId))
                        {
                            context.Mark_Insert(abitId, examInEntryId, val, _dateExam, false, false, false, _vedId, null, null);
                            marksCount++;
                        }
                    }

                    foreach (string abId in slReplaceMark.Keys)
                    {
                        DataSet dss = bdc.GetDataSet(string.Format("SELECT Id, EntryId FROM ed.qAbiturient WHERE Id = '{0}' ", abId));
                        DataRow drr = dss.Tables[0].Rows[0];

                        string        examInPr = Exams.GetExamInEntryId(_examId, drr["EntryId"].ToString());
                        List <string> list     = Exams.GetExamIdsInEntry(drr["EntryId"].ToString());
                        if (list.Contains(_examId))
                        {
                            Guid abitId        = new Guid(abId);
                            int  examInEntryId = int.Parse(examInPr);
                            int  val           = int.Parse(slReplaceMark[abId]);

                            context.Mark_DeleteByAbitExamId(abitId, examInEntryId);
                            context.Mark_Insert(abitId, examInEntryId, val, _dateExam, false, false, false, _vedId, null, null);

                            marksCount++;
                        }
                    }

                    context.ExamsVed_UpdateLoad(true, _vedId);

                    // transaction.Complete();

                    lblIsLoad.Text  = "Загружена";
                    btnLoad.Enabled = false;
                    // }

                    MessageBox.Show(marksCount + " записей добавлено.", "Выполнено");
                }
            }
            catch (Exception exc)
            {
                WinFormsServ.Error(exc.Message);
            }
        }