コード例 #1
0
ファイル: ExamsVedList.cs プロジェクト: wladengine/Foreigners
        private void btnLock_Click(object sender, EventArgs e)
        {
            if (ExamVedId == null)
            {
                return;
            }

            if (MainClass.IsOwner() || MainClass.IsCrypto() || MainClass.IsPasha())
            {
                if (MessageBox.Show("Ведомость будет закрыта для редактирования, продолжить? ", "Внимание", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        using (PriemEntities context = new PriemEntities())
                        {
                            using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew))
                            {
                                List <int> lstNumbers = new List <int>();
                                int        curNum;
                                foreach (DataGridViewRow dgvr in dgvList.Rows)
                                {
                                    Guid persId = new Guid(dgvr.Cells["Id"].Value.ToString());

                                    curNum = GetRandomNumber(ref lstNumbers);
                                    context.ExamsVedHistory_UpdateNumber(ExamVedId, persId, curNum);
                                }

                                context.ExamsVed_UpdateLock(true, ExamVedId);

                                btnChange.Enabled = false;
                                btnDelete.Enabled = false;
                                btnLock.Enabled   = false;
                                lblLocked.Visible = true;
                                MessageBox.Show("Выполнено");

                                btnPrintSticker.Enabled = true;
                                tbCountCell.Enabled     = true;

                                transaction.Complete();
                            }
                        }
                    }

                    catch (Exception ex)
                    {
                        WinFormsServ.Error("Ошибка обновления данных: " + ex.Message);
                    }
                }
            }
            else
            {
                WinFormsServ.Error("Невозможно закрытие ведомостей, недостаточно прав");
            }
        }
コード例 #2
0
        //дополнительная инициализация контролов
        private void InitControls()
        {
            InitFocusHandlers();
            bdc = MainClass.Bdc;

            try
            {
                if (MainClass.IsCrypto() || MainClass.IsPasha())
                {
                    btnCreateCsv.Visible = true;
                }
                else
                {
                    btnCreateCsv.Visible = false;
                }

                using (PriemEntities context = new PriemEntities())
                {
                    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();
                    UpdateVedRoomList();

                    UpdateDataGrid();

                    cbFaculty.SelectedIndexChanged     += new EventHandler(cbFaculty_SelectedIndexChanged);
                    cbStudyBasis.SelectedIndexChanged  += new EventHandler(cbStudyBasis_SelectedIndexChanged);
                    cbExamVed.SelectedIndexChanged     += new EventHandler(cbExamVed_SelectedIndexChanged);
                    cbExamVedRoom.SelectedIndexChanged += new EventHandler(cbExamVedRoom_SelectedIndexChanged);
                }
            }
            catch (Exception ex)
            {
                WinFormsServ.Error("Ошибка при инициализации формы ведомостей: " + ex.Message);
            }
        }
コード例 #3
0
ファイル: ExamsVedList.cs プロジェクト: wladengine/Foreigners
        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("Невозможно создание наклеек, недостаточно прав");
            }
        }
コード例 #4
0
        /// <summary>
        /// extra information for open - what smi are enabled
        /// </summary>
        /// <param name="path"></param>
        public void OpenHelp(string path)
        {
            try
            {
                bFirstRun = false;
                // убирает все IsOpen для данного пользователя
                MainClass.DeleteAllOpenByHolder();

                tsslMain.Text          = string.Format("Открыта база: Прием в СПбГУ {0} {1}; ", MainClass.sPriemYear, path);
                MainClass.dirTemplates = string.Format(@"{0}\Templates", Application.StartupPath);

                MainClass.InitQueryBuilder();

                ShowProtocolWarning();

                //предупреждение об рабочем режиме базы
                //MessageBox.Show("Уважаемые пользователи!\nСистема находится в рабочем режиме.\nВведение тестовых записей не допускается.", "Внимание");

                if (MainClass.IsOwner())
                {
                    return;
                }

                // магистратура!
                if (MainClass.dbType == PriemType.PriemMag || MainClass.dbType == PriemType.PriemForeigners)
                {
                    smiOlympAbitList.Visible     = false;
                    smiOlymps.Visible            = false;
                    smiOlymp2Competition.Visible = false;
                    smiOlymp2Mark.Visible        = false;
                }
                else
                {
                    smiOnlineChanges.Visible = false;
                    smiLoad.Visible          = false;
                }

                smiRatingList.Visible       = false;
                smiOrderNumbers.Visible     = false;
                smiOlymps.Visible           = false;
                smiCreateVed.Visible        = false;
                smiBooks.Visible            = false;
                smiCrypto.Visible           = false;
                smiFBS.Visible              = false;
                smiExport.Visible           = false;
                smiImport.Visible           = false;
                smiExamsVedRoomList.Visible = false;
                //smiProblemSolver.Visible = false;
                smiEntryView.Visible    = false;
                smiDisEntryView.Visible = false;


                smiEGEStatistics.Visible = false;
                smiDynamics.Visible      = false;
                smiFormA.Visible         = false;
                smiForm2.Visible         = false;

                smiAbitFacultyIntesection.Visible = false;
                smiRegionStat.Visible             = false;
                smiOlympStatistics.Visible        = false;

                // Разделение видимости меню
                if (MainClass.IsFacMain())
                {
                    smiOlymps.Visible                 = true;
                    smiCreateVed.Visible              = true;
                    smiExamsVedRoomList.Visible       = true;
                    smiRatingList.Visible             = true;
                    smiEntryView.Visible              = true;
                    smiDisEntryView.Visible           = true;
                    smiAbitFacultyIntesection.Visible = true;
                    smiExport.Visible                 = true;
                }

                if (MainClass.IsEntryChanger())
                {
                    smiBooks.Visible           = true;
                    smiEnterManual.Visible     = false;
                    smiRatingListPasha.Visible = false;
                    smiRatingList.Visible      = true;
                    smiExport.Visible          = true;
                }

                if (MainClass.IsPasha())
                {
                    smiCrypto.Visible       = true;
                    smiBooks.Visible        = true;
                    smiRatingList.Visible   = true;
                    smiFBS.Visible          = true;
                    smiOrderNumbers.Visible = true;
                    smiExport.Visible       = true;
                    smiEntryView.Visible    = true;
                    smiDisEntryView.Visible = true;
                    smiEnterManual.Visible  = true;
                    smiAppeal.Visible       = true;
                    smiDecryptor.Visible    = true;

                    //Паша попросил добавить себе
                    smiCreateVed.Visible        = true;
                    smiExamsVedRoomList.Visible = true;

                    smiRatingListPasha.Visible = true;

                    smiEGEStatistics.Visible = true;
                    smiDynamics.Visible      = true;
                    smiFormA.Visible         = true;
                    smiForm2.Visible         = true;

                    smiAbitFacultyIntesection.Visible = true;
                    smiRegionStat.Visible             = true;
                    smiOlympStatistics.Visible        = true;
                }

                if (MainClass.IsRectorat())
                {
                    smiEGEStatistics.Visible = true;
                    smiFormA.Visible         = true;

                    smiExport.Visible = true;

                    smiAbitFacultyIntesection.Visible = true;
                    smiRegionStat.Visible             = true;
                    smiOlympStatistics.Visible        = true;
                }

                if (MainClass.IsSovetnik() || MainClass.IsSovetnikMain())
                {
                    smiAbitFacultyIntesection.Visible = true;
                }

                if (MainClass.IsCrypto())
                {
                    smiCrypto.Visible           = true;
                    smiExamsVedRoomList.Visible = true;
                    smiAppeal.Visible           = false;
                    smiDecryptor.Visible        = false;
                    smiLoadMarks.Visible        = false;
                }

                if (MainClass.IsCryptoMain())
                {
                    smiCrypto.Visible           = true;
                    smiAppeal.Visible           = true;
                    smiExamsVedRoomList.Visible = true;

                    //глава шифровалки тоже хочет создавать ведомости
                    smiCreateVed.Visible = true;

                    smiDecryptor.Visible = false;
                    smiLoadMarks.Visible = false;
                }

                if (MainClass.IsPrintOrder())
                {
                    smiEntryView.Visible = true;
                }

                //временно
                smiImport.Visible = false;


                Form frm;
                if (MainClass._config.ValuesList.Keys.Contains("lstAbitDef"))
                {
                    bool lstAbitDef = bool.Parse(MainClass._config.ValuesList["lstAbitDef"]);

                    if (lstAbitDef)
                    {
                        frm = new ListAbit(this);
                        smiListAbit.Checked   = true;
                        smiListPerson.Checked = false;
                    }
                    else
                    {
                        if (MainClass.dbType == PriemType.PriemMag)
                        {
                            frm = new ApplicationInetList();
                        }
                        else
                        {
                            frm = new PersonInetList();
                        }

                        smiListPerson.Checked = true;
                        smiListAbit.Checked   = false;
                    }
                }
                else
                {
                    frm = new PersonInetList();
                }

                ShowProtocolWarning();

                frm.Show();
            }

            catch (Exception exc)
            {
                WinFormsServ.Error("Ошибка инициализации " + exc.Message);
            }
        }