Exemplo n.º 1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            InputDocumentHead head = new InputDocumentHead();

            head.DocType      = (int)cmbDocType.SelectedValue;
            head.DocumentDate = dtpDate.Value;
            head.Factory      = (int)cmbFactory.SelectedValue;

            try
            {
                if (chkParent.Checked)
                {
                    switch (head.DocType)
                    {
                    case 1:
                    case 3:
                        Document = InputDocFactory.CreateDocument(head, Data, int.Parse(txtParent.Text));
                        break;

                    case 2:
                    case 4:
                        Document = InputDocFactory.CreateDocument(head, Data, int.Parse(txtParent.Text));
                        break;
                    }
                }
                else
                {
                    switch (head.DocType)
                    {
                    case 1:
                    case 3:
                        Document = InputDocFactory.CreateDocument(head, Data);
                        break;

                    case 2:
                    case 4:
                        Document = InputDocFactory.CreateDocument(head, Data);
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorMsgBox.Show("Ошибка", "Ошибка создания документа.\n" + exception.Message, exception.ToString());
                return;
            }
            if (Document != null)
            {
                string message = "Документ № " + head.DocumentNumber.ToString() + " успешно создан.\nПерейти к редактированию?";
                if (MessageBox.Show(message, "Информация", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    this.DialogResult = DialogResult.Yes;
                }
            }
            else
            {
                ErrorMsgBox.Show("Ошибка", "Ошибка создания документа.", "Документ с таким номером уже существует.");
            }
            this.Close();
        }
Exemplo n.º 2
0
 private void btnEditPlan_Click(object sender, EventArgs e)
 {
     if (gridPlanDocuments.SelectedRows.Count > 0)
     {
         try
         {
             IInputDocument doc  = InputDocFactory.LoadDocument((int)gridPlanDocuments.SelectedRows[0].Cells["DocumentID"].Value, GlobalValues.Instance);
             FormInputDoc   edit = new FormInputDoc(doc, GlobalValues.Instance);
             edit.Show();
             edit.Activate();
         }
         catch (Exception exc)
         {
             ErrorMsgBox.Show("Ошибка", "Ошибка редактирования документа\r\n" + exc.Message, exc.ToString());
             return;
         }
     }
 }