Ejemplo n.º 1
0
 private void BtnDataG_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtPrice.Text) || cboBrand.SelectedIndex == -1 ||
         cboCategory.SelectedIndex == -1 || cboFamily.SelectedIndex == -1 || cboSupplier.SelectedIndex == -1 ||
         cboMoney.SelectedIndex == -1)
     {
         frmMessageBoxFillNull frm = new frmMessageBoxFillNull();
         frm.ShowDialog();
     }
     else
     {
         if (flag == 1)
         {
             /*
              * btnDataG.Enabled = true;
              * txtName.Enabled = false;
              * txtPrice.Enabled = false;
              *
              * cboCategory.Enabled = false;
              * cboFamily.Enabled = false;
              * cboBrand.Enabled = false;
              *
              * cboSupplier.Enabled = false;
              * cboMoney.Enabled = false;
              */
             AlmacenDisecWS.category   c     = (AlmacenDisecWS.category)cboCategory.SelectedValue;
             AlmacenDisecWS.family     f     = (AlmacenDisecWS.family)cboFamily.SelectedValue;
             AlmacenDisecWS.brand      b     = (AlmacenDisecWS.brand)cboBrand.SelectedValue;
             AlmacenDisecWS.supplier   sup   = (AlmacenDisecWS.supplier)cboSupplier.SelectedValue;
             AlmacenDisecWS.storehouse store = (AlmacenDisecWS.storehouse)cboStorehouse.SelectedValue;
             string name           = txtName.Text;
             double price          = double.Parse(txtPrice.Text);
             AlmacenDisecWS.tool t = new AlmacenDisecWS.tool();
             t.brand.brand_id                 = b.brand_id;
             t.name_item                      = name;
             t.price                          = price;
             t.family.id_family               = f.id_family;
             t.suppliers.id_supplier          = sup.id_supplier;
             t.stock.storehouse.id_storehouse = store.id_storehouse;
             int a = 0;
             if (cboMoney.Text == "SOLES")
             {
                 a = 1;
             }
             else
             {
                 a = 2;
             }
             string waytopay = cboWayofPay.Text;
             int    result   = serviceDA.insertTool(t, a, waytopay);
         }
         else
         {
             frmMessageBoxNew frm = new frmMessageBoxNew();
             frm.ShowDialog();
         }
     }
 }
Ejemplo n.º 2
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();
                    }
                }
            }
        }
        private void btnSearch_Click_1(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtSearch.Text))
            {
                list.Clear();
                int cont = 0;
                AlmacenDisecWS.supplier[] a = new AlmacenDisecWS.supplier[100];

                a    = serviceDA.queryAllSupplier();
                cont = a.Count();
                for (int i = 0; i < cont; i++)
                {
                    Supplier s = new Supplier();
                    //     s = (Supplier)a[i];
                    s.id_supplier    = a[i].id_supplier;
                    s.supplier_name  = a[i].supplier_name;
                    s.city.id_city   = a[i].city.id_city;
                    s.city.name_city = a[i].city.name_city;
                    s.email          = a[i].email;
                    s.ruc            = a[i].ruc;
                    s.phone_number   = a[i].phone_number;
                    s.adress         = a[i].adress;
                    list.Add(s);
                }


                /*  s2.supplier_name = a[1].supplier_name;
                 * s2.city.id_city = a[1].city.id_city;
                 * s2.city.name_city = a[1].city.name_city;
                 * s3.supplier_name = a[2].supplier_name;
                 * s3.city.id_city = a[2].city.id_city;
                 * s3.city.name_city = a[2].city.name_city;
                 *
                 * s2.email = a[1].email;
                 * s2.ruc = a[1].ruc;
                 * s2.phone_number = a[1].phone_number;
                 * s2.adress = a[1].adress;
                 * s3.email = a[2].email;
                 * s3.ruc = a[2].ruc;
                 * s3.phone_number = a[2].phone_number;
                 * s3.adress = a[2].adress;
                 *
                 *
                 *
                 *
                 * list.Add(s2);
                 * list.Add(s3);*/

                btnModify.Enabled             = true;
                dgvSearch.AutoGenerateColumns = false;
                dgvSearch.DataSource          = list;
            }
            else
            {
                BindingList <Supplier>  list2 = new BindingList <Supplier>();
                AlmacenDisecWS.supplier s     = new AlmacenDisecWS.supplier();
                String name = txtSearch.Text;

                s = serviceDA.querySupplierByName(name);
                if (s.id_supplier == 0)
                {
                    frmMessageBoxSearchNull frm = new frmMessageBoxSearchNull();
                    frm.ShowDialog();
                }
                else
                {
                    Supplier s2 = new Supplier();

                    s2.id_supplier = s.id_supplier;

                    s2.supplier_name              = s.supplier_name;
                    s2.city.id_city               = s.city.id_city;
                    s2.city.name_city             = s.city.name_city;
                    s2.email                      = s.email;
                    s2.ruc                        = s.ruc;
                    s2.phone_number               = s.phone_number;
                    s2.adress                     = s.adress;
                    dgvSearch.AutoGenerateColumns = false;
                    list2.Add(s2);
                    dgvSearch.DataSource = list2;
                    btnModify.Enabled    = true;
                }

                //Insertar el codigo de busqueda por nombre
            }
        }