Пример #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!filledValues())
            {
                //MessageBox.Show("Complete la información");
            }
            else
            {
                //serviceDA = new DBControllerWSClient();
                purchase p = new purchase();
                p.state         = 1;
                p.serialCode    = txtSerialCode.Text;
                p.totalPurchase = float.Parse(txtTotal.Text);
                //para el supplier
                supplier c = new supplier();
                serviceDA  = new DBControllerWSClient();
                c          = serviceDA.querySupplierByCode(txtIdProv.Text);
                p.supplier = c;
                //para los purchase lanes
                purchaseLane[] salelanes;
                salelanes = new purchaseLane[dgvPurchaseDetails.RowCount - 1];
                for (int i = 0; i < dgvPurchaseDetails.RowCount - 1; i++)
                {
                    purchaseLane purchaselane = new purchaseLane();
                    purchaselane.subtotal = float.Parse(dgvPurchaseDetails.Rows[i].Cells[4].Value.ToString());
                    purchaselane.quantity = int.Parse(dgvPurchaseDetails.Rows[i].Cells[3].Value.ToString());
                    //purchaselane.purchase = p;
                    product pr = new product();
                    pr = serviceDA.queryProductBySKUCode(dgvPurchaseDetails.Rows[i].Cells[0].Value.ToString());
                    purchaselane.product = pr;
                    salelanes[i]         = purchaselane;
                }
                p.currency      = "Soles";
                p.purchaseLanes = salelanes;
                //Cursor.Current = Cursors.WaitCursor;
                int salio = serviceDA.insertPurchase(p);
                if (salio == 1)
                {
                    MessageBox.Show("Se ingresó la compra correctamente");
                }
                else
                {
                    MessageBox.Show("¡Hubo un problema!");
                }
                //Cursor.Current = Cursors.Arrow;

                this.Close();
            }
        }