public clsCabeceraComprobante consultaComprobante(decimal NumeroCom, int idEmpresa) { try { clsCabeceraComprobante cabecera = new clsCabeceraComprobante(); EntitiesContabilidad2 ent = new EntitiesContabilidad2(); var cab = (from q in ent.CabeceraComprobante where q.IdEmpresa == idEmpresa && q.numero_comprobante == NumeroCom select q).First(); cabecera.fecha = Convert.ToDateTime(cab.fecha); cabecera.glosa = cab.glosa; cabecera.IdEmpresa = cab.IdEmpresa; cabecera.numero_comprobante = cab.numero_comprobante; cabecera.periodo_contable = Convert.ToDecimal(cab.periodo_contable); cabecera.periodo_contable_IdAFiscal = Convert.ToDecimal(cab.periodo_contable_IdAFiscal); //////////////////////////////// var det = (from q in ent.DetalleComprobante where q.IdEmpresa == idEmpresa && q.cabecera_comprobante == NumeroCom select q); List <clsDetalleComprobante> lista = new List <clsDetalleComprobante>(); foreach (var item in det) { clsDetalleComprobante detalle = new clsDetalleComprobante(); detalle.cuenta = item.cuenta; detalle.debe = item.debe; detalle.haber = item.haber; detalle.linea_comprobante = item.linea_comprobante; lista.Add(detalle); } cabecera.Detalle = lista; return(cabecera); } catch (Exception) { return(null); } }
public List <clsDetalleComprobante> get() { try { cabecera.fecha = dtFecha.Value; cabecera.glosa = txtGlosa.Text; cabecera.IdEmpresa = 1; ////////// gridViewComprobante.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None; List <clsDetalleComprobante> lista = new List <clsDetalleComprobante>(); for (int i = 0; i < gridViewComprobante.RowCount; i++) { clsDetalleComprobante clas = new clsDetalleComprobante(); clas.cuenta = Convert.ToString(gridViewComprobante.GetRowCellValue(i, colcuenta)); clas.debe = Convert.ToDecimal(gridViewComprobante.GetRowCellValue(i, coldebe)); clas.haber = Convert.ToDecimal(gridViewComprobante.GetRowCellValue(i, colhaber)); clas.IdEmpresa = Convert.ToInt32(gridViewComprobante.GetRowCellValue(i, colIdEmpresa)); clas.linea_comprobante = Convert.ToInt32(gridViewComprobante.GetRowCellValue(i, collinea_comprobante)); if (clas.debe > 0 && clas.haber > 0) { if (clas.debe > clas.haber) { gridViewComprobante.SetRowCellValue(i, colhaber, 0); } else { gridViewComprobante.SetRowCellValue(i, coldebe, 0); } } lista.Add(clas); } gridViewComprobante.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; return(lista); } catch (Exception) { return(null); } }