Esempio n. 1
0
        private void getDetalleCompra(string id)
        {
            DataTable data = new DetalleCompra().Mostrar(id);

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

                foreach (DataRow row in data.Rows)
                {
                    string pid, n, c, cu, t;
                    pid = row[0].ToString();
                    n   = row[1].ToString();
                    c   = row[2].ToString();
                    cu  = row[3].ToString();
                    t   = row[4].ToString();
                    detalleCompra.Rows.Add(pid, n, c, cu, t);
                }
            }
        }
Esempio n. 2
0
        private void saveDetalle(int tipo)
        {
            DetalleCompra d = new DetalleCompra();

            foreach (DataGridViewRow r in detalleCompra.Rows) //(int i = 0; i < detalleCompra.Rows.Count; i++)
            {                                                 //detalleCompra.Rows[i].Cells[0].Value.ToString()
                d.CompraID  = txtCodigoCompra.Text;
                d.ProdID    = int.Parse(r.Cells[0].Value.ToString());
                d.Cant      = int.Parse(r.Cells[2].Value.ToString());
                d.UnitPrice = decimal.Parse(r.Cells[3].Value.ToString());
                d.Total     = decimal.Parse(r.Cells[4].Value.ToString());
                historialCosto(d.ProdID, d.UnitPrice);
                if (tipo == 1)
                {
                    d.Insertar();
                }
                else
                {
                    d.Editar();
                }
            }
        }