Exemple #1
0
        private void CommitEvent(object sender, EventArgs e)
        {
            ComboBox receiverBox     = (ComboBox)Utils.FindControl(this, "receiverBox");
            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 = receiverBox.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       text     = textBox.Text;
                Company      receiver = (Company)receiverBox.SelectedItem;

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

                if (titleValidated && documentCodeValidated)
                {
                    document.Type         = type;
                    document.DocumentCode = int.Parse(documentCodeString);
                    document.Title        = title;
                    document.Text         = text;
                    document.Receiver     = receiver;
                    Dispose();
                    Close();
                }
                else
                {
                    MessageBox.Show("Нерпавильно введенные данные!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Одно из полей пустое!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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);
            }
        }