Пример #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Company company = null;

            try
            {
                company = new Company(
                    companyID,
                    CompanyNameBox.Text,
                    int.Parse(CompanyRaitingBox.Text),
                    FormOfompanyBox.Text
                    );
            }catch (Exception ex)
            {
                SetError("Incorrect data");
                return;
            }
            AdressOfDepartment[] adresses = AdressBox
                                            .Items
                                            .Cast <AdressOfDepartment>().
                                            ToArray();

            company.AddAdress(adresses);
            if (saveCompany(company))
            {
                Close();
            }
            else
            {
                SetError("Unable to save");
            }
        }