Exemplo n.º 1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (flag == true)
            {
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtRuc.Text) || String.IsNullOrEmpty(txtAddress.Text) ||
                    String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPhone.Text) || cboCountry.SelectedIndex == -1 || cboCity.SelectedIndex == -1)
                {
                    frmMessageBoxFillNull frm = new frmMessageBoxFillNull();
                    frm.ShowDialog();
                }

                else
                {
                    frmMessageBoxSave frm = new frmMessageBoxSave();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AlmacenDisecWS.supplier s  = new AlmacenDisecWS.supplier();
                        AlmacenDisecWS.city     ci = new AlmacenDisecWS.city();
                        AlmacenDisecWS.country  co = new AlmacenDisecWS.country();
                        s.email         = txtEmail.Text;
                        s.ruc           = txtRuc.Text;
                        s.adress        = txtAddress.Text;
                        s.phone_number  = Int32.Parse(txtPhone.Text);
                        s.supplier_name = txtName.Text;
                        s.city          = (AlmacenDisecWS.city)cboCity.SelectedItem;
                        s.city.country  = (AlmacenDisecWS.country)cboCountry.SelectedItem;
                        int result = serviceDA.insertSupplier(s);


                        reiniciar();
                        frmSearchSupplier fm = Owner as frmSearchSupplier;
                        fm.dgvSearch.AutoGenerateColumns = false;
                        fm.dgvSearch.DataSource          = "";

                        this.Close();
                    }
                }
            }


            else
            {
                if (String.IsNullOrEmpty(txtCode.Text) || String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtRuc.Text) || String.IsNullOrEmpty(txtAddress.Text) ||
                    String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPhone.Text))
                {
                    frmMessageBoxFillNull frm2 = new frmMessageBoxFillNull();
                    frm2.ShowDialog();
                }
                else
                {
                    frmMessageBoxSave frm = new frmMessageBoxSave();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AlmacenDisecWS.supplier s = new AlmacenDisecWS.supplier();
                        //falta que le quiten el pais al actualizar
                        s.id_supplier   = Int32.Parse(txtCode.Text);
                        s.email         = txtEmail.Text;
                        s.ruc           = txtRuc.Text;
                        s.adress        = txtAddress.Text;
                        s.phone_number  = Int32.Parse(txtPhone.Text);
                        s.supplier_name = txtName.Text;

                        int result = serviceDA.updateSupplier(s);

                        reiniciar();
                        frmSearchSupplier fm = Owner as frmSearchSupplier;
                        fm.txtSearch.Clear();
                        fm.dgvSearch.AutoGenerateColumns = false;
                        fm.dgvSearch.DataSource          = "";

                        this.Close();
                    }
                }
            }
        }
Exemplo n.º 2
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();
                    }
                }
            }
        }