private void CommitEditEvent(object sender, EventArgs e)
        {
            Control salaryBox = Utils.FindControl(this, "salaryBox");

            bool filled = !String.IsNullOrWhiteSpace(salaryBox.Text);

            if (filled)
            {
                string salaryString = salaryBox.Text;

                bool salaryValidated = DirectorFormValidator.ValidateSalary(salaryString);

                if (salaryValidated)
                {
                    director.Salary = int.Parse(salaryBox.Text);

                    Controls.Remove(salaryBox);
                    Controls.Remove((Control)sender);
                    AddInfoForms();
                }
                else
                {
                    MessageBox.Show("Неправильно введенные данные!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Одно из полей пустое!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void CommitButton_Click(object sender, EventArgs e)
        {
            Control      salaryBox    = Utils.FindControl(this, "salaryBox");
            SignatureBox signatureBox = (SignatureBox)Utils.FindControl(this, "signatureBox");

            bool filled = !String.IsNullOrWhiteSpace(salaryBox.Text);

            if (filled)
            {
                string salaryString    = Utils.FindControl(this, "salaryBox").Text;
                bool   salaryValidated = DirectorFormValidator.ValidateSalary(salaryString);

                Bitmap bmp = new Bitmap(signatureBox.Width, signatureBox.Height);
                signatureBox.DrawToBitmap(bmp, new Rectangle(0, 0, signatureBox.Width, signatureBox.Height));
                byte[] signature = Utils.ImageToByte(bmp);

                if (salaryValidated)
                {
                    Salary         = int.Parse(salaryString);
                    Signature      = signature;
                    CorrectOnClose = true;
                    Close();
                    Dispose();
                }
                else
                {
                    MessageBox.Show("Нерпавильно введенные данные!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CorrectOnClose = false;
                }
            }
            else
            {
                MessageBox.Show("Одно из полей пустое!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CorrectOnClose = false;
            }
        }