Esempio n. 1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            {
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtMinQuantity.Text) || String.IsNullOrEmpty(txtSerie.Text) ||
                    String.IsNullOrEmpty(txtPrice.Text) || cboBrand.SelectedIndex == -1 || cboCategory.SelectedIndex == -1 ||
                    cboFamily.SelectedIndex == -1 || cboUnit.SelectedIndex == -1 || cboStatus.SelectedIndex == -1 ||
                    cboSupplier.SelectedIndex == -1 || cboMoney.SelectedIndex == -1)
                {
                    frmMessageBoxFillNull frm = new frmMessageBoxFillNull();
                    frm.ShowDialog();
                }
                else
                {
                    if (flag == 2)
                    {
                        if (String.IsNullOrEmpty(txtCode.Text))
                        {
                            frmMessageBoxSave frm = new frmMessageBoxSave();
                            if (frm.ShowDialog() == DialogResult.OK)
                            {
                                String name = txtName.Text;
                                //Category cat = new category(name,1);
                                //Se llama al insert

                                frmMessageBoxAdd frm2 = new frmMessageBoxAdd();
                                if (frm2.ShowDialog() == DialogResult.OK)
                                {
                                    int id_c = 0;
                                    AlmacenDisecWS.materialDetail detail = new AlmacenDisecWS.materialDetail();
                                    AlmacenDisecWS.material       m      = new AlmacenDisecWS.material();
                                    AlmacenDisecWS.category       c      = new AlmacenDisecWS.category();
                                    detail.measure        = (AlmacenDisecWS.measureUnit)cboUnit.SelectedItem;
                                    detail.serie_material = txtSerie.Text;
                                    m.min_quantity        = Int32.Parse(txtMinQuantity.Text);
                                    m.brand  = (AlmacenDisecWS.brand)cboUnit.SelectedItem;
                                    m.family = (AlmacenDisecWS.family)cboFamily.SelectedItem;
                                    c        = (AlmacenDisecWS.category)cboCategory.SelectedItem;
                                    /// m.supplier = (AlmacenDisecWS.supplier)cbosupplier.SelectedItem
                                    m.price     = Double.Parse(txtPrice.Text);
                                    m.name_item = txtName.Text;
                                    //     m.material_details.  = detail;

                                    if (cboMoney.SelectedItem.ToString() == "SOLES")
                                    {
                                        id_c = 1;
                                    }
                                    else
                                    {
                                        if (cboMoney.SelectedItem.ToString() == "DOLARES")
                                        {
                                            id_c = 2;
                                        }
                                    }

                                    m.family.category.category_id   = c.category_id;
                                    m.family.category.category_name = c.category_name;

                                    //  int result = serviceDA.insertMaterial(m,id_c) ;
                                    txtCode.Clear();
                                    txtSerie.Clear();
                                    cboStatus.SelectedIndex = -1;
                                }
                                else
                                {
                                    reiniciar();
                                }
                            }
                        }
                    }
                    else
                    {
                        if (flag == 0)
                        {
                            if (String.IsNullOrEmpty(txtCode.Text))
                            {
                                frmMessageBoxNew frm2 = new frmMessageBoxNew();
                                frm2.ShowDialog();
                            }
                            else
                            {
                                frmMessageBoxSave frm = new frmMessageBoxSave();
                                if (frm.ShowDialog() == DialogResult.OK)
                                {
                                    //  int id = Int32.Parse(txtId.Text);
                                    String name = txtName.Text;
                                    //  Category cat = (Category)cboCategory.SelectedIndex;
                                    //Category cat = new category(name,0);
                                    //Se llama al update
                                    reiniciar();
                                }
                            }
                        }
                        else
                        {
                            if (flag == 1)
                            {
                                frmMessageBoxDataGeneral frm2 = new frmMessageBoxDataGeneral();
                                frm2.ShowDialog();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            {
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtSerie.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 == 2)
                    {
                        if (String.IsNullOrEmpty(txtCode.Text))
                        {
                            frmMessageBoxSave frm = new frmMessageBoxSave();
                            if (frm.ShowDialog() == DialogResult.OK)
                            {
                                String name = txtName.Text;
                                //Category cat = new category(name,1);
                                //Se llama al insert

                                frmMessageBoxAdd frm2 = new frmMessageBoxAdd();
                                if (frm2.ShowDialog() == DialogResult.OK)
                                {
                                    txtCode.Clear();
                                    txtSerie.Clear();
                                    //cboStatus.SelectedIndex = -1;
                                }
                                else
                                {
                                    reiniciar();
                                }
                            }
                        }
                    }
                    else
                    {
                        if (flag == 0)
                        {
                            if (String.IsNullOrEmpty(txtCode.Text))
                            {
                                frmMessageBoxNew frm2 = new frmMessageBoxNew();
                                frm2.ShowDialog();
                            }
                            else
                            {
                                frmMessageBoxSave frm = new frmMessageBoxSave();
                                if (frm.ShowDialog() == DialogResult.OK)
                                {
                                    //  int id = Int32.Parse(txtId.Text);
                                    String name = txtName.Text;
                                    //  Category cat = (Category)cboCategory.SelectedIndex;
                                    //Category cat = new category(name,0);
                                    //Se llama al update
                                    reiniciar();
                                }
                            }
                        }
                        else
                        {
                            if (flag == 1)
                            {
                                frmMessageBoxDataGeneral frm2 = new frmMessageBoxDataGeneral();
                                frm2.ShowDialog();
                            }
                        }
                    }
                }
            }
        }