Example #1
0
        private void getDetalleVenta(string id)
        {
            DataTable data = new DetalleVenta().Mostrar(id);

            if (data != null)
            {
                detalleVenta.Rows.Clear();

                foreach (DataRow row in data.Rows)
                {
                    string pid, n, c, pu, d, i, t;
                    pid = row[0].ToString();
                    n   = row[1].ToString();
                    c   = row[2].ToString();
                    pu  = row[3].ToString();
                    d   = row[4].ToString();
                    i   = row[5].ToString();
                    t   = row[6].ToString();
                    detalleVenta.Rows.Add(pid, n, c, pu, d, i, t);
                }
            }
        }
Example #2
0
        private void saveDetalle(int tipo)
        {
            DetalleVenta d = new DetalleVenta();

            foreach (DataGridViewRow r in detalleVenta.Rows)
            {
                d.ProductoID     = int.Parse(r.Cells[0].Value.ToString());
                d.VentaID        = txtCodigoVenta.Text;
                d.Cantidad       = int.Parse(r.Cells[2].Value.ToString());
                d.PrecioUnitario = decimal.Parse(r.Cells[3].Value.ToString());
                d.Descuento      = decimal.Parse(r.Cells[4].Value.ToString());
                d.Impuesto       = decimal.Parse(r.Cells[5].Value.ToString());
                d.Total          = decimal.Parse(r.Cells[6].Value.ToString());

                if (tipo == 1)
                {
                    d.Insertar();
                }
                else
                {
                    d.Editar();
                }
            }
        }