private void btnCreateAdd_Click(object sender, EventArgs e)
        {
            if (MainClass.IsFacMain() || MainClass.IsOwner() || MainClass.IsPasha())
            {
                using (PriemEntities context = new PriemEntities())
                {
                    int?stBas = null;
                    if (cbExamVed.SelectedItem.ToString().Contains("г/б"))
                    {
                        stBas = 1;
                    }
                    else if (cbExamVed.SelectedItem.ToString().Contains("дог"))
                    {
                        stBas = 2;
                    }

                    extExamsVed ved = (from ev in context.extExamsVed
                                       where ev.Id == ExamVedId
                                       select ev).FirstOrDefault();

                    DateTime passDate = ved.Date;
                    int      examId   = ved.ExamId;

                    SelectExamCrypto frm = new SelectExamCrypto(this, StudyLevelGroupId, FacultyId, stBas, passDate, examId);
                    frm.Show();
                }
            }
        }
        public ExamsVedCard(ExamsVedList owner, Guid?vedId)
        {
            InitializeComponent();

            _Id        = vedId;
            this.owner = owner;
            bdc        = MainClass.Bdc;

            using (PriemEntities context = new PriemEntities())
            {
                extExamsVed ved = (from vd in context.extExamsVed
                                   where vd.Id == _Id
                                   select vd).FirstOrDefault();

                this.facultyId    = ved.FacultyId;
                this.passDate     = ved.Date;
                this.isAdditional = ved.IsAdditional;
                this.examId       = ved.ExamId;
                this.studyBasisId = ved.StudyBasisId;
                this.isAddVed     = false;
                this.addCount     = 0;

                this.studyLevelGroupId = ved.StudyLevelGroupId;
            }

            InitControls();
        }
        //печать
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (ExamVedId == null)
            {
                return;
            }

            try
            {
                WordDoc  wd = new WordDoc(string.Format(@"{0}\Templates\CryptoExamsVed.dot", Application.StartupPath));
                TableDoc td = wd.Tables[0];

                using (PriemEntities context = new PriemEntities())
                {
                    extExamsVed ved = (from ev in context.extExamsVed
                                       where ev.Id == ExamVedId
                                       select ev).FirstOrDefault();

                    wd.Fields["Faculty"].Text    = cbFaculty.Text.ToLower();
                    wd.Fields["Exam"].Text       = ved.ExamName;
                    wd.Fields["StudyBasis"].Text = Util.ToStr(ved.StudyBasisId == null ? "все" : ved.StudyBasisName);
                    wd.Fields["Date"].Text       = ved.Date.ToShortDateString();
                    wd.Fields["VedNum"].Text     = ved.Number.ToString();

                    int i = 1;

                    // печать из грида
                    foreach (DataGridViewRow dgvr in dgvList.Rows)
                    {
                        td[0, i] = i.ToString();
                        td[1, i] = dgvr.Cells["Фамилия"].Value.ToString();
                        td[2, i] = dgvr.Cells["Имя"].Value.ToString();
                        td[3, i] = dgvr.Cells["Отчество"].Value.ToString();
                        td[4, i] = DateTime.Parse(dgvr.Cells["Дата_рождения"].Value.ToString()).ToShortDateString();
                        td[5, i] = dgvr.Cells["Ид_номер"].Value.ToString();
                        td[6, i] = FacultyId.ToString();
                        td[7, i] = ved.ExamName;
                        td[8, i] = ved.ExamId.ToString();
                        td[9, i] = ved.Date.ToShortDateString();;

                        td.AddRow(1);
                        i++;
                    }

                    td.DeleteLastRow();
                }
            }
            catch (Exception exc)
            {
                WinFormsServ.Error("Ошибка вывода в Word: \n" + exc.Message);
            }
        }
Exemple #4
0
        //дополнительная инициализация контролов
        private void InitControls()
        {
            InitFocusHandlers();

            this.CenterToParent();
            //this.MdiParent = MainClass.mainform;
            bdc = MainClass.Bdc;

            lblAdd.Text = string.Empty;

            using (PriemEntities context = new PriemEntities())
            {
                extExamsVed exVed = (from ev in context.extExamsVed
                                     where ev.Id == _vedId
                                     select ev).FirstOrDefault();

                _examId       = exVed.ExamId.ToString();
                _dateExam     = exVed.Date;
                _facultyId    = exVed.FacultyId.ToString();
                _studybasisId = exVed.StudyBasisId.ToString();

                lblFaculty.Text += exVed.FacultyName;

                if (exVed.StudyBasisId == null)
                {
                    lblStudyBasis.Text += "все";
                }
                else
                {
                    lblStudyBasis.Text += exVed.StudyBasisName;
                }

                lblExam.Text += exVed.ExamName;
                lblDate.Text += exVed.Date.ToShortDateString();
                if (exVed.IsAddVed)
                {
                    lblAdd.Text += "дополнительная (" + exVed.AddCount.ToString() + ")";
                }

                if (MainClass.IsCryptoMain() || MainClass.IsPasha())
                {
                    btnLoad.Visible = true;
                }
                else
                {
                    btnLoad.Visible = false;
                }
            }
        }
        private void btnPrintSticker_Click(object sender, EventArgs e)
        {
            if (ExamVedId == null)
            {
                return;
            }

            if (MainClass.IsOwner() || MainClass.IsCrypto() || MainClass.IsPasha() || MainClass.IsCryptoMain())
            {
                FileStream fileS    = null;
                string     savePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Sticker.pdf";

                float fontsize = 8;

                try
                {
                    using (PriemEntities context = new PriemEntities())
                    {
                        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
                        document.SetMargins(18, 18, 36, 5);

                        using (fileS = new FileStream(savePath, FileMode.Create))
                        {
                            BaseFont             bfTimes = BaseFont.CreateFont(string.Format(@"{0}\times.ttf", MainClass.dirTemplates), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
                            iTextSharp.text.Font font    = new iTextSharp.text.Font(bfTimes, 10);

                            PdfWriter pw = PdfWriter.GetInstance(document, fileS);
                            document.Open();

                            int cntCells = 2;
                            int.TryParse(tbCountCell.Text.Trim(), out cntCells);

                            string examId;
                            string examName;
                            string examDate;
                            string facId;
                            string vedNumber;

                            extExamsVed ved = (from ev in context.extExamsVed
                                               where ev.Id == ExamVedId
                                               select ev).FirstOrDefault();

                            examId    = ved.ExamId.ToString();
                            examName  = ved.ExamName.ToString();
                            examDate  = ved.Date.ToShortDateString();
                            vedNumber = ved.Number.ToString();
                            facId     = FacultyId.ToString();

                            DataSet dsPersons = bdc.GetDataSet(string.Format("SELECT DISTINCT ed.extPerson.Id, ed.extPerson.PersonNum as RegNum, ed.extPerson.FIO, ed.ExamsVedHistory.PersonVedNumber " +
                                                                             "FROM ed.extPerson LEFT JOIN ed.ExamsVedHistory ON ed.ExamsVedHistory.PersonId = ed.extPerson.Id WHERE ed.ExamsVedHistory.ExamsVedId = '{0}' ORDER BY FIO ", ExamVedId.ToString()));

                            PdfPTable t            = new PdfPTable(3);
                            float     pgW          = (PageSize.A4.Width - 36) / 3;
                            float[]   headerwidths = { pgW, pgW, pgW };
                            t.SetWidths(headerwidths);
                            t.WidthPercentage           = 100f;
                            t.SpacingBefore             = 10f;
                            t.SpacingAfter              = 10f;
                            t.DefaultCell.MinimumHeight = 120;

                            int cellsNum = (dsPersons.Tables[0].Rows.Count) * (cntCells + 1);
                            int ost      = cellsNum % 3;

                            foreach (DataRow drr in dsPersons.Tables[0].Rows)
                            {
                                string text = drr["FIO"].ToString() + "\n" + drr["RegNum"].ToString() + " " + facId + "\n";
                                text += examDate + " " + examName;

                                Barcode128 barcode1 = new Barcode128();
                                barcode1.Code = vedNumber + "==" + drr["PersonVedNumber"].ToString() + "-";

                                Barcode128 barcode2 = new Barcode128();
                                barcode2.Code = vedNumber + "==" + drr["PersonVedNumber"].ToString() + "-";

                                PdfContentByte        cb   = pw.DirectContent;
                                iTextSharp.text.Image img1 = barcode1.CreateImageWithBarcode(cb, null, null);
                                img1.ScaleAbsolute(80f, 60f);

                                iTextSharp.text.Image img2 = barcode2.CreateImageWithBarcode(cb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.WHITE);
                                img2.ScaleAbsolute(80f, 60f);


                                PdfPTable ptPl = new PdfPTable(1);
                                float[]   hwh  = { pgW };
                                ptPl.SetWidthPercentage(hwh, PageSize.A4);

                                PdfPCell clPlText = new PdfPCell(new Phrase(text, new iTextSharp.text.Font(bfTimes, fontsize)));
                                clPlText.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER;
                                clPlText.PaddingBottom       = 2;
                                clPlText.PaddingTop          = 2;
                                clPlText.Border = iTextSharp.text.Rectangle.NO_BORDER;

                                PdfPCell clPlBarc = new PdfPCell();
                                clPlBarc.AddElement(img1);
                                clPlBarc.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER;
                                clPlBarc.PaddingTop          = 1;
                                clPlBarc.PaddingLeft         = 40;
                                clPlBarc.Border = iTextSharp.text.Rectangle.NO_BORDER;

                                ptPl.AddCell(clPlText);
                                ptPl.AddCell(clPlBarc);

                                PdfPCell pcell = new PdfPCell(ptPl);
                                pcell.PaddingTop    = 6;
                                pcell.PaddingBottom = 6;
                                pcell.PaddingLeft   = 6;
                                pcell.PaddingRight  = 6;
                                pcell.FixedHeight   = 100;
                                pcell.Border        = iTextSharp.text.Rectangle.NO_BORDER;

                                t.AddCell(pcell);

                                PdfPCell pcell1;
                                for (int i = 0; i < cntCells; i++)
                                {
                                    ptPl = new PdfPTable(1);
                                    ptPl.SetWidthPercentage(hwh, PageSize.A4);

                                    clPlText = new PdfPCell();
                                    clPlText.AddElement(img2);
                                    clPlText.PaddingLeft  = 40;
                                    clPlText.PaddingRight = 40;
                                    clPlText.PaddingTop   = 20;
                                    clPlText.Border       = iTextSharp.text.Rectangle.NO_BORDER;

                                    clPlBarc = new PdfPCell(new Phrase((i + 1).ToString(), new iTextSharp.text.Font(bfTimes, fontsize)));
                                    clPlBarc.HorizontalAlignment = iTextSharp.text.Rectangle.ALIGN_CENTER;
                                    clPlBarc.PaddingTop          = 1;
                                    clPlBarc.Border = iTextSharp.text.Rectangle.NO_BORDER;

                                    ptPl.AddCell(clPlText);
                                    ptPl.AddCell(clPlBarc);

                                    pcell1             = new PdfPCell(ptPl);
                                    pcell1.FixedHeight = 100;
                                    pcell1.Border      = iTextSharp.text.Rectangle.NO_BORDER;
                                    t.AddCell(pcell1);
                                }
                            }

                            for (int i = 0; i < 3 - ost; i++)
                            {
                                PdfPCell pc = new PdfPCell();
                                pc.Border = iTextSharp.text.Rectangle.NO_BORDER;
                                t.AddCell(pc);
                            }

                            if (t != null)
                            {
                                document.Add(t);
                            }

                            document.Close();

                            Process pr = new Process();

                            pr.StartInfo.Verb     = "Print";
                            pr.StartInfo.FileName = string.Format(savePath);
                            pr.Start();

                            pr.Close();
                        }
                    }
                }

                catch (Exception exc)
                {
                    WinFormsServ.Error(exc.Message);
                }
                finally
                {
                    if (fileS != null)
                    {
                        fileS.Dispose();
                    }
                }
            }

            else
            {
                WinFormsServ.Error("Невозможно создание наклеек, недостаточно прав");
            }
        }
Exemple #6
0
        //дополнительная инициализация контролов
        private void InitControls()
        {
            InitFocusHandlers();

            this.CenterToParent();
            //this.MdiParent = MainClass.mainform;

            if (!_isModified)
            {
                dgvMarks.ReadOnly = true;
                btnSave.Text      = "Изменить";
            }

            lblAdd.Text = string.Empty;

            using (PriemEntities context = new PriemEntities())
            {
                extExamsVed exVed = (from ev in context.extExamsVed
                                     where ev.Id == _vedId
                                     select ev).FirstOrDefault();

                _isAdditional = exVed.IsAddVed;
                _examId       = exVed.ExamId.ToString();
                _dateExam     = exVed.Date.ToString("yyyyMMdd");
                _facultyId    = exVed.FacultyId.ToString();
                _studybasisId = exVed.StudyBasisId.ToString();
                _vedNum       = exVed.Number.ToString();

                lblFaculty.Text += exVed.FacultyName;

                if (exVed.StudyBasisId == null)
                {
                    lblStudyBasis.Text += "все";
                }
                else
                {
                    lblStudyBasis.Text += exVed.StudyBasisName;
                }

                lblExam.Text += exVed.ExamName;
                lblDate.Text += exVed.Date.ToShortDateString();
                if (exVed.IsAddVed)
                {
                    lblAdd.Text += "дополнительная (" + exVed.AddCount.ToString() + ")";
                }

                lblVedType.Text = _isOral ? "устная часть" : "письменная часть";


                if (exVed.IsLoad)
                {
                    _isLoad                = true;
                    _isModified            = false;
                    dgvMarks.ReadOnly      = true;
                    btnSave.Text           = "Изменить";
                    btnSave.Enabled        = false;
                    lblIsLoad.Text         = "Загружена";
                    tbPersonVedNum.Enabled = false;
                }
            }
        }
Exemple #7
0
        //дополнительная инициализация контролов
        private void InitControls()
        {
            InitFocusHandlers();

            this.CenterToParent();
            //this.MdiParent = MainClass.mainform;
            bdc = MainClass.Bdc;

            slReplaceMark = new SortedList <string, string>();
            slNewMark     = new SortedList <string, string>();

            dgvMarks.ReadOnly = true;

            lblAdd.Text = string.Empty;

            using (PriemEntities context = new PriemEntities())
            {
                extExamsVed exVed = (from ev in context.extExamsVed
                                     where ev.Id == _vedId
                                     select ev).FirstOrDefault();

                _isAdditional = exVed.IsAddVed;
                _examId       = exVed.ExamId.ToString();
                _dateExam     = exVed.Date;
                _facultyId    = exVed.FacultyId.ToString();
                _studybasisId = exVed.StudyBasisId.ToString();
                _vedNum       = exVed.Number.ToString();

                lblFaculty.Text += exVed.FacultyName;

                if (exVed.StudyBasisId == null)
                {
                    lblStudyBasis.Text += "все";
                }
                else
                {
                    lblStudyBasis.Text += exVed.StudyBasisName;
                }

                lblExam.Text += exVed.ExamName;
                lblDate.Text += exVed.Date.ToShortDateString();
                if (exVed.IsAddVed)
                {
                    lblAdd.Text += "дополнительная (" + exVed.AddCount.ToString() + ")";
                }

                btnPrintVed.Enabled = false;

                if (exVed.IsLoad)
                {
                    _isLoad             = true;
                    dgvMarks.ReadOnly   = true;
                    lblIsLoad.Text      = "Загружена";
                    btnPrintVed.Enabled = true;
                }

                if ((MainClass.IsCryptoMain() || MainClass.IsPasha()) && !exVed.IsLoad)
                {
                    btnLoad.Visible = true;
                }
                else
                {
                    btnLoad.Visible = false;
                }

                if (MainClass.IsPasha())
                {
                    btnPrintVed.Enabled = true;
                }

                btnDoubleLanguage.Visible = false;//MainClass.IsPasha();
            }
        }
Exemple #8
0
        private void btnPrintVed_Click(object sender, EventArgs e)
        {
            if (!_isLoad)
            {
                return;
            }

            try
            {
                WordDoc  wd = new WordDoc(string.Format(@"{0}\Templates\CryptoEnterMarks.dot", Application.StartupPath));
                TableDoc td = wd.Tables[0];

                //переменные

                string   examId;
                string   examName;
                DateTime examDate;
                string   facultyId;

                using (PriemEntities context = new PriemEntities())
                {
                    extExamsVed exVed = (from ev in context.extExamsVed
                                         where ev.Id == _vedId
                                         select ev).FirstOrDefault();

                    examId    = _examId;
                    examName  = exVed.ExamName;
                    examDate  = _dateExam;
                    facultyId = _facultyId;

                    wd.Fields["Faculty"].Text    = exVed.FacultyName;
                    wd.Fields["Exam"].Text       = examName;
                    wd.Fields["StudyBasis"].Text = exVed.StudyBasisId == null ? "все" : exVed.StudyBasisName;
                    wd.Fields["Date"].Text       = examDate.ToShortDateString();
                    wd.Fields["VedNum"].Text     = exVed.Number.ToString();

                    int i = 1;

                    var persMark = from evh in context.ExamsVedHistory
                                   join pers in context.extForeignPerson
                                   on evh.PersonId equals pers.Id
                                   where evh.ExamsVedId == _vedId
                                   select new
                    {
                        evh.ExamsVedId,
                        pers.Surname,
                        pers.Name,
                        pers.SecondName,
                        pers.BirthDate,
                        pers.PersonNum,
                        evh.PersonId,
                        evh.PersonVedNumber,
                        evh.Mark,
                        evh.OralMark
                    };

                    foreach (var pm in persMark)
                    {
                        td[0, i] = i.ToString();
                        td[1, i] = pm.Surname;
                        td[2, i] = pm.Name;
                        td[3, i] = pm.SecondName;
                        td[4, i] = pm.BirthDate.ToShortDateString();
                        td[5, i] = pm.PersonNum;
                        td[6, i] = facultyId;
                        td[7, i] = examName;
                        td[8, i] = examId;
                        td[9, i] = examDate.ToShortDateString();

                        int?sumMark = 0;
                        if (pm.Mark == null && pm.OralMark == null)
                        {
                            sumMark = null;
                        }
                        else
                        {
                            sumMark = (pm.Mark ?? 0) + (pm.OralMark ?? 0);
                        }

                        td[10, i] = sumMark == null ? "" : sumMark.ToString();

                        td.AddRow(1);
                        i++;
                    }
                    td.DeleteLastRow();
                }
            }
            catch (Exception exc)
            {
                WinFormsServ.Error("Ошибка вывода в Word: \n" + exc.Message);
            }
        }
        //дополнительная инициализация
        protected virtual void InitControls()
        {
            this.MdiParent = MainClass.mainform;
            this.CenterToParent();
            InitFocusHandlers();

            using (PriemEntities context = new PriemEntities())
            {
                extExamsVed ved = (from vd in context.extExamsVed
                                   where vd.Id == vedId
                                   select vd).FirstOrDefault();

                this.facultyId    = ved.FacultyId;
                this.passDate     = ved.Date.Date;
                this.isAdditional = ved.IsAdditional;
                this.examId       = ved.ExamId;
                this.studyBasisId = ved.StudyBasisId;
                this.isAddVed     = false;
                this.addCount     = 0;

                Dgv = dgvRight;
                dtPassDate.Enabled = false;

                tbExam.Text      = ved.ExamName;
                dtPassDate.Value = passDate;
                if (isAddVed)
                {
                    dtPassDate.Enabled = false;
                    lblAdd.Visible     = true;
                    if (addCount == 0)
                    {
                        lblAddCount.Text = "";
                    }
                    else
                    {
                        lblAddCount.Text = "(" + addCount + ")";
                    }
                }
                if (vedRoomId != null)
                {
                    tbRoomNumber.Enabled = false;
                }

                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", MainClass.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);
            }
        }