private void MostrarLista() { var oDocumento = new Documento_Cab(); oDocumento.filtro = txtBusqueda.Text.Trim(); var LDocumentoListarUso = oDocumento.ListarUso(); dgvGastos.DataSource = LDocumentoListarUso; }
private void btnGuardar_Click(object sender, EventArgs e) { //Exige que se ingrese los datos antes de guardar if (!validarDatos()) { return; } //Confirmacion para guardar if (MessageBox.Show("¿Desea guardar el Documento de Gasto?", Global.tituloPres, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ var oCabecera = new Documento_Cab(); var oLista = new List<Documento_Lin>(); oCabecera.ccosto = txtCosto.Text; oCabecera.doc = "DG"; oCabecera.idPersona = (int)cboEncargado.SelectedValue; oCabecera.idEstado = (string)cboEstado.SelectedValue; oCabecera.total = Convert.ToDecimal(txtTotalEgreso.Text); oCabecera.usr = Global._Usr; oCabecera.idEstado = cboEstado.Text.Substring(0, 1); for (int j = 0; j <= dgvPartida.Rows.Count - 1; j++) { var oDetalle = new Documento_Lin(); oDetalle.idPartida = dgvPartida.Rows[j].Cells[colPartida.Name].Value.ToString(); oDetalle.cantidad = Convert.ToInt16(dgvPartida.Rows[j].Cells[ColCantidad.Name].Value); oDetalle.precio = Convert.ToDecimal(dgvPartida.Rows[j].Cells[ColPrecioUnd.Name].Value); oDetalle.total = Convert.ToDecimal(dgvPartida.Rows[j].Cells[colTotal.Name].Value); oLista.Add(oDetalle); } if (Estado == 1) { oCabecera.Insertar(oLista); txtAnioMes.Text = oCabecera.ej + " - " + oCabecera.mes; txtDoc_Numero.Text = oCabecera.numero; DialogResult = DialogResult.OK; MessageBox.Show("El documento " + oCabecera.ccosto + "-" + oCabecera.numero + " se guardó satisfactoriamente.", Global.tituloPres, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { oCabecera.ccosto = oDocumento_Cab.ccosto; oCabecera.doc = oDocumento_Cab.doc; oCabecera.numero = oDocumento_Cab.numero; oCabecera.Actualizar(oLista); } DialogResult = DialogResult.OK; MessageBox.Show("El documento " + oCabecera.ccosto + "-"+ oCabecera.numero+ " se modifico satisfactoriamente.", Global.tituloPres, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); }