Пример #1
0
        private void btnAddPartner_Click(object sender, EventArgs e)
        {
            Partner partner = new Partner();

            partner.id                   = int.Parse(tBox_addPartner_id.Text);
            partner.name                 = tBox_AddPartner_name.Text;
            partner.adress               = tBox_AddPartner_adress.Text;
            partner.headquarters         = tBox_AddPartner_headquarters.Text;
            partner.phoneNumber          = tBox_AddPartner_phoneNum.Text;
            partner.identificationNumber = tBox_AddPartner_IdentificationNum.Text;
            partner.director             = tBox_addPartner_director.Text;
            partner.type                 = (Enums.PartnerType)cmb_addPartner_type.SelectedItem;

            //Add it do products list
            DeliveryHolder.partners.Add(partner);
            try
            {
                DeliveryClient.InsertPartner(partner);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to insert partner to database");
            }


            clearTab(tabPagePartner);
            tBox_addPartner_id.Text = (DeliveryHolder.partners.Count == 0 ? 0 :
                                       (from elem in DeliveryHolder.partners select elem.id).Max() + 1).ToString();
        }