private void SelectSecretaryEvent(object sender, EventArgs e)
        {
            ComboBox secretariesBox = (ComboBox)Utils.FindControl(this, "secretariesBox");

            if (secretariesBox.SelectedItem == null)
            {
                MessageBox.Show("Персона не выбрана!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Secretary         secretary         = (Secretary)secretariesBox.SelectedValue;
                SecretaryInfoForm secretaryInfoForm = new SecretaryInfoForm(secretary);
                secretaryInfoForm.Activate();
                secretaryInfoForm.Show();
            }
        }
Пример #2
0
        private void CommitEvent(object sender, EventArgs e)
        {
            ComboBox companiesBox    = (ComboBox)Utils.FindControl(this, "companiesBox");
            ComboBox typeBox         = (ComboBox)Utils.FindControl(this, "typeBox");
            Control  documentCodeBox = Utils.FindControl(this, "documentCodeBox");
            Control  textBox         = Utils.FindControl(this, "textBox");
            Control  titleBox        = Utils.FindControl(this, "titleBox");

            bool filled = companiesBox.SelectedItem != null &&
                          typeBox.SelectedItem != null &&
                          !String.IsNullOrWhiteSpace(documentCodeBox.Text) &&
                          !String.IsNullOrWhiteSpace(documentCodeBox.Text);

            if (filled)
            {
                string       title = titleBox.Text;
                DocumentType type  = (DocumentType)typeBox.SelectedItem;
                string       documentCodeString = documentCodeBox.Text;
                string       content            = textBox.Text;
                Company      receiver           = (Company)companiesBox.SelectedItem;

                bool titleValidated        = DocumentFormValidator.ValidateTitle(title);
                bool documentCodeValidated = DocumentFormValidator.ValidateDocumentCode(documentCodeString);

                if (titleValidated && documentCodeValidated)
                {
                    Document          document = secretary.CreateDocument(type, int.Parse(documentCodeString), title, content, receiver);
                    SecretaryInfoForm form     = (SecretaryInfoForm)Application.OpenForms["SecretaryInfoForm"];
                    form.UpdateCreatedDocumentsBox();
                    Dispose();
                    Close();
                }
                else
                {
                    MessageBox.Show("Нерпавильно введенные данные!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Одно из полей пустое!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }