private void ShowMaterialPermit()
        {
            lblPerson.Text           = materialPermit.Person;
            lblMatPermitVehicle.Text = materialPermit.VehicleMark + " " + materialPermit.LicensePlate;

            dgvItemList.DataSource = materialPermit.GetItemList(Database);
        }
        private void MdLoadingBgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            MaterialPermit materialDocument = e.Result as MaterialPermit;

            bsMaterialDocumentItem.DataSource = materialDocument;

            tboxMdPerson.Text       = materialDocument.Person;
            tboxMdVehicleMark.Text  = materialDocument.VehicleMark;
            tboxMdLicensePlate.Text = materialDocument.LicensePlate;
            tboxMdCreator.Text      = materialDocument.Creator.ToString();
            pboxCreatedImage.Image  = materialDocument.CreatedImage;
            tboxMdCreatedDate.Text  = materialDocument.CreatedDate.ToString("dd.MM.yyyy HH:mm");

            pboxMdSigned.Image = materialDocument.SignedImage;
            if (materialDocument.SignedFlag != 0)
            {
                tboxSigner.Text       = materialDocument.Signer.ToString();
                tboxMdSignedDate.Text = materialDocument.SignedDate.ToString("dd.MM.yyyy HH:mm");
            }
            else
            {
                tboxSigner.Text       = "";
                tboxMdSignedDate.Text = "";
            }

            btnSignMd.Enabled = (materialDocument.CreatedFlag > 0 && materialDocument.SignedFlag < 1);
            btnLockMd.Enabled = (materialDocument.EntryFlag <1 && materialDocument.SignedFlag> -1 && materialDocument.CreatedFlag > 0);

            pboxMdEntry.Image = materialDocument.EntryImage;

            if (materialDocument.EntryFlag != 0)
            {
                tboxMdEntryPoint.Text = materialDocument.EntryPoint.ToString();
                tboxMdEntryDate.Text  = materialDocument.EntryDate.ToString("dd.MM.yyyy HH:mm");
            }
            else
            {
                tboxMdEntryDate.Text  = "";
                tboxMdEntryPoint.Text = "";
            }

            bsMdItems.DataSource = materialDocument.GetItemList(Database);

            temporaryTimer.Stop();
            temporaryTimer.Dispose();
            temporaryTimer = null;

            pbarMdLoading.Visible = false;

            temporaryBgWorker.Dispose();
            temporaryBgWorker = null;
        }
        private void bsDocumentList_CurrentChanged(object sender, EventArgs e)
        {
            clearNewTimer.Stop();

            if (bsDocumentList.Current != null)
            {
                MaterialPermit document = (MaterialPermit)bsDocumentList.Current;
                dgvItemList.DataSource = document.GetItemList(Database);

                editDocumentTool.Enabled   = (document.CreateFlag != 1);
                deleteDocumentTool.Enabled = (document.CreateFlag != 1);

                CheckPermissions(document);

                if (document.IsNew)
                {
                    clearNewTimer.Start();
                }
            }
        }