Пример #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            {
                if (String.IsNullOrEmpty(txtNameStorehouse.Text) ||
                    String.IsNullOrEmpty(txtPhone.Text) || cboCity.SelectedIndex == -1 ||
                    String.IsNullOrEmpty(txtAddressStorehouse.Text))
                {
                    frmMessageBoxFillNull frm = new frmMessageBoxFillNull();
                    frm.ShowDialog();
                }
                else
                {
                    if (flag == true)
                    {
                        if (String.IsNullOrEmpty(txtId.Text))
                        {
                            AlmacenDisecWS.storehouse store = new AlmacenDisecWS.storehouse();

                            frmMessageBoxSave frm = new frmMessageBoxSave();
                            if (frm.ShowDialog() == DialogResult.OK)
                            {
                                string name        = txtNameStorehouse.Text;
                                int    phoneNumber = int.Parse(txtPhone.Text);
                                string address     = txtAddressStorehouse.Text;
                                store.address         = address;
                                store.phone_number    = phoneNumber;
                                store.storehouse_name = name;
                                AlmacenDisecWS.city city = new AlmacenDisecWS.city();
                                city       = (AlmacenDisecWS.city)cboCity.SelectedItem;
                                store.city = city;
                                int result = serviceDA.insertStorehouse(store);
                            }
                            frmSearchStoreHouse fm = Owner as frmSearchStoreHouse;
                            fm.dgvSearch.AutoGenerateColumns = false;
                            fm.dgvSearch.DataSource          = "";

                            this.Close();
                        }
                        else
                        {
                            frmMessageBoxDataGeneral frm2 = new frmMessageBoxDataGeneral();
                            frm2.ShowDialog();
                        }
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(txtNameStorehouse.Text) ||
                            String.IsNullOrEmpty(txtPhone.Text) || cboCity.SelectedIndex == -1 ||
                            String.IsNullOrEmpty(txtAddressStorehouse.Text))
                        {
                            frmMessageBoxFillNull frm2 = new frmMessageBoxFillNull();
                            frm2.ShowDialog();
                        }
                        else
                        {
                            AlmacenDisecWS.storehouse store = new AlmacenDisecWS.storehouse();

                            frmMessageBoxSave frm = new frmMessageBoxSave();
                            if (frm.ShowDialog() == DialogResult.OK)
                            {
                                int    id          = int.Parse(txtId.Text);
                                string name        = txtNameStorehouse.Text;
                                int    phoneNumber = int.Parse(txtPhone.Text);
                                string address     = txtAddressStorehouse.Text;
                                store.id_storehouse   = id;
                                store.address         = address;
                                store.phone_number    = phoneNumber;
                                store.storehouse_name = name;
                                AlmacenDisecWS.city city = new AlmacenDisecWS.city();
                                city       = (AlmacenDisecWS.city)cboCity.SelectedItem;
                                store.city = city;
                                int result = serviceDA.updateStorehouse(store);
                            }
                        }
                        frmSearchStoreHouse fm = Owner as frmSearchStoreHouse;
                        fm.dgvSearch.AutoGenerateColumns = false;
                        fm.dgvSearch.DataSource          = "";

                        this.Close();
                    }
                }
            }
        }