private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                dataGridView1.Rows[e.RowIndex].Selected = true;

                var newProtocolId =
                    (int) dataGridView1.SelectedRows[0].Cells[0].Value;
                var protocol = (NewVipAvtoSet.ProtocolsRow)newVipAvtoSet.GetRowById(Constants.ProtocolsTableName, newProtocolId);
                NewVipAvtoSet.MesuresRow[] mesures = protocol.GetMesuresRows();

                _document2 = new PrintProtocolDocument(protocol,  newVipAvtoSet);
                printPreviewControl2.Document = _document2;
            }
        }
        public ProtocolReportForm(NewVipAvtoSet.ProtocolsRow protocolRow, NewVipAvtoSet.MesuresRow[] mesures,
            NewVipAvtoSet set, bool printNow = false)
        {
            _set = set;
            _printNow = printNow;

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language);

            InitializeComponent();

            _document = new PrintProtocolDocument(protocolRow, _set);
            printPreviewControl1.Document = _document;

            if (_printNow)
            {
                _document.Print();
            }

            Text += protocolRow.BlankNumber;

            ResizeEnd += ProtocolReportForm_ResizeEnd;
        }
        public void MesureTest()
        {
            var set = new NewVipAvtoSet();
            set.AddMechanic("ivan", "ivanov", "ivanovich");
            set.AddOperator("ivan", "ivanov", "valn", "dfdss", "Оператор");
            set.SetCurrentOperator("valn");
            set.AddGroup(2007, "M1", 0, true);
            set.AddNormative(set.Groups[0].IdGroup, 0, 30);
            set.AddProtocol("4324342", set.GetShortMechanicName(set.Mechanics[0].IdMechanic), DateTime.Now,
                set.Groups[0].IdGroup, true, DateTime.Now.AddDays(365), true, 0);

            set.AddMesure(1, 1, set.Protocols[0].IdProtocol, set.Groups[0].IdGroup);
            set.Update(typeof (NewVipAvtoSet.MesuresRow));
            Assert.AreEqual(1, set.Mesures.Count);

            var document = new PrintProtocolDocument(set.Protocols[0],  set);
            document.Print();

            var document2 = new PrintJournalDocument(set.Protocols.ToArray(), DateTime.Now.AddDays(-25), DateTime.Now,
                set);
            document2.Print();

            set.AddProtocol("43243432", set.GetShortMechanicName(set.Mechanics[0].IdMechanic), DateTime.Now,
                set.Groups[0].IdGroup, false, DateTime.Now.AddDays(365), false, 1);
            set.AddPhoto(new Bitmap(400, 878), set.Protocols[1].IdProtocol);

            document = new PrintProtocolDocument(set.Protocols[1], set);
            document.Print();

            set.AddGroup(2007, "M1", 1, false);
            set.AddNormative(set.Groups[1].IdGroup, 0, 30);

            set.AddProtocol("43243432", set.GetShortMechanicName(set.Mechanics[0].IdMechanic), DateTime.Now,
                set.Groups[1].IdGroup, false, DateTime.Now.AddDays(365), false, 2);
            set.AddPhoto(new Bitmap(652, 400), set.Protocols[2].IdProtocol);
            document = new PrintProtocolDocument(set.Protocols[2], set);
            document.Print();

            Assert.AreEqual("4324342",
                set.GetRowById(Constants.ProtocolsTableName, set.Protocols[0].IdProtocol)[1].ToString());
            set.RemoveRowById(Constants.ProtocolsTableName, set.Protocols[0].IdProtocol);

            set.LockMechanic(set.Mechanics[0].IdMechanic);
        }
        private void maskedTextBox1_TextChanged(object sender, EventArgs e)
        {
            if (maskedTextBox1.Text != @"     -")
            {
                string blank = label80.Text + maskedTextBox1.Text;

                NewVipAvtoSet.ProtocolsRow row = newVipAvtoSet.GetProtocolByBlankId(blank);

                if (row != null)
                {
                    NewVipAvtoSet.MesuresRow[] mesures = row.GetMesuresRows();
                    _document = new PrintProtocolDocument(row, newVipAvtoSet);
                    printPreviewControl1.Document = _document;

                    maskedTextBox1.BackColor = Color.LightGreen;
                    button1.Enabled = true;
                }
                else
                {
                    if (printPreviewControl1.Document != null)
                    {
                        _document = null;
                        printPreviewControl1.Document = null;
                    }
                    maskedTextBox1.BackColor = Color.LightPink;
                    button1.Enabled = false;
                }
            }
            else
            {
                maskedTextBox1.BackColor = Color.LightGoldenrodYellow;
                button1.Enabled = false;
            }
        }