public bool RegeneraAsientos(int n_IdEmpresa, int n_IdMesTrabajo, int n_IdAnoTrabajo, int n_IdLibro, int n_TipoRegistro) { // n_TipoRegistro = 1 INGRESOS n_TipoRegistro = 2 EGRESOS DataTable dtLis = new DataTable(); bool b_result = false; int n_row = 0; int n_idreg = 0; CD_tes_tesoreria miFun = new CD_tes_tesoreria(); CD_con_diario o_Conta = new CD_con_diario(); CN_con_diario funCon = new CN_con_diario(); miFun.mysConec = mysConec; o_Conta.mysConec = mysConec; //b_result = o_Conta.EliminarLibroMes(n_IdLibro, n_IdAnoTrabajo, n_IdMesTrabajo, n_IdEmpresa); b_result = true; //o_Conta.EliminarLibroMes(n_IdLibro, n_IdAnoTrabajo, n_IdMesTrabajo, n_IdEmpresa); if (b_result == true) { miFun.Listar(n_IdEmpresa, n_IdAnoTrabajo, n_IdMesTrabajo, n_TipoRegistro); dtLis = miFun.DtLista; // objRegistros.Listar(STU_SISTEMA.EMPRESAID, STU_SISTEMA.ANOTRABAJO, Convert.ToInt32(CboMeses.SelectedValue), 1); dtLis = funDatos.DataTableOrdenar(dtLis, "c_numreg"); for (n_row = 0; n_row <= dtLis.Rows.Count - 1; n_row++) { string c_NumAsi = dtLis.Rows[n_row]["c_numreg"].ToString().Substring(4, 4); n_idreg = Convert.ToInt32(dtLis.Rows[n_row]["n_id"].ToString()); funCon.mysConec = mysConec; funCon.STU_SISTEMA = STU_SISTEMA; //funCon.GenerarAsientoVentas(STU_SISTEMA.EMPRESAID, n_idreg, STU_SISTEMA.ANOTRABAJO, STU_SISTEMA.MESTRABAJO, 14, c_NumAsi); funCon.GenerarAsientoTesoreria(STU_SISTEMA.EMPRESAID, n_idreg, STU_SISTEMA.ANOTRABAJO, STU_SISTEMA.MESTRABAJO, 1, c_NumAsi, n_TipoRegistro); //c_NumAsi = funCon.c_NewNumAsiento; //miFun.AgregarNumAsi(n_idreg, c_NumAsi); } b_result = true; } return(b_result); }
public bool RegeneraAsientos(int n_IdEmpresa, int n_IdMesTrabajo, int n_IdAnoTrabajo, int n_IdLibro, int n_IdTipoCompra) { DataTable dtLis = new DataTable(); bool b_result = false; int n_row = 0; int n_idreg = 0; CD_log_compras miFun = new CD_log_compras(); CD_con_diario o_Conta = new CD_con_diario(); CN_con_diario funCon = new CN_con_diario(); // hacer seguimientyo para ver si esta generando bien miFun.mysConec = mysConec; o_Conta.mysConec = mysConec; b_result = o_Conta.EliminarLibroMes(n_IdLibro, n_IdAnoTrabajo, n_IdMesTrabajo, n_IdEmpresa); if (b_result == true) { if (miFun.Listar(n_IdEmpresa, n_IdMesTrabajo, n_IdAnoTrabajo, n_IdTipoCompra) == false) { b_OcurrioError = miFun.b_ocurrioError; c_ErrorMensaje = miFun.c_ErrorMensaje; n_ErrorNumber = miFun.n_ErrorNumber; return(b_result); } dtLis = miFun.dtLista; if (n_IdLibro == 8) { dtLis = fundatos.DataTableFiltrar(dtLis, "(n_idtipdoc IN(2,4,5,6,11,13,15,16,17,21,38))"); } if (n_IdLibro == 32) { dtLis = fundatos.DataTableFiltrar(dtLis, "(n_idtipdoc = 3)"); } dtLis = fundatos.DataTableOrdenar(dtLis, "c_numreg"); bool b_newasi = false; for (n_row = 0; n_row <= dtLis.Rows.Count - 1; n_row++) { b_newasi = false; string c_NumAsi = dtLis.Rows[n_row]["c_numreg"].ToString(); if (c_NumAsi == "") { b_newasi = true; } n_idreg = Convert.ToInt32(dtLis.Rows[n_row]["n_id"].ToString()); funCon.mysConec = mysConec; funCon.STU_SISTEMA = STU_SISTEMA; if (n_IdLibro == 8) { funCon.GenerarAsientoCompras(STU_SISTEMA.EMPRESAID, n_idreg, STU_SISTEMA.ANOTRABAJO, STU_SISTEMA.MESTRABAJO, 8, c_NumAsi); } if (n_IdLibro == 32) { funCon.GenerarAsientoCompras(STU_SISTEMA.EMPRESAID, n_idreg, STU_SISTEMA.ANOTRABAJO, STU_SISTEMA.MESTRABAJO, 32, c_NumAsi); } if (b_newasi == true) { c_NumAsi = funCon.c_NewNumAsiento; miFun.AgregarNumAsi(n_idreg, c_NumAsi); } } } b_result = true; return(b_result); }
public bool Actualizar(BE_EST_MOVIMIENTOS e_Movimiento, bool b_GenerarCargo) { bool booOk = false; DatosMySql xMiFuncion = new DatosMySql(); CD_con_diario funCon = new CD_con_diario(); int intFila = 0; MySqlTransaction trans; int n_IdGenerado = 0; DataTable dtresul = new DataTable(); string c_numasi = "0000"; mysConec = xMiFuncion.ReAbrirConeccion(mysConec); trans = mysConec.BeginTransaction(); funCon.mysConec = mysConec; try { e_Movimiento.n_iddocven = 0; if (b_GenerarCargo == true) { if (b_GENERARASIENTO == true) { // OBTENEMOS EL ULTIMO ASIENTO funCon.ObtenerUltimoAsiento(e_Documento.n_anotra, e_Documento.n_idmes, 14, e_Documento.n_idemp); dtresul = funCon.dtLista; c_numasi = Convert.ToInt32(dtresul.Rows[0]["c_newnumero"]).ToString("0000"); } e_Documento.c_numreg = c_numasi; if (xMiFuncion.StoreEjecutar("vta_ventas_insertar", e_Documento, mysConec, 0) == true) { // AGREGAMOS EL DETALLE DE LA VENTA n_IdGenerado = Convert.ToInt32(xMiFuncion.intIdGenerado); e_Documento.n_id = Convert.ToInt64(n_IdGenerado); for (intFila = 0; intFila <= l_Diario.Count - 1; intFila++) { l_Diario[intFila].n_oriid = n_IdGenerado; l_Diario[intFila].c_numasi = c_numasi; } for (intFila = 0; intFila <= l_DocumentoDet.Count - 1; intFila++) { l_DocumentoDet[intFila].n_idvta = n_IdGenerado; if (xMiFuncion.StoreEjecutar("vta_ventasdet_insertar", l_DocumentoDet[intFila], mysConec, null) == false) { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } // AGREGAMOS LOS DOCUMENTOS DE LA VENTA for (intFila = 0; intFila <= l_DetDoc.Count - 1; intFila++) { l_DetDoc[intFila].n_idvta = Convert.ToInt32(n_IdGenerado); if (xMiFuncion.StoreEjecutar("vta_ventasdoc_insertar", l_DetDoc[intFila], mysConec, null) == false) { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } // ESTO ES PARA LA FACTURACION ELECTRONICA for (intFila = 0; intFila <= l_DetOCT.Count - 1; intFila++) { l_DetOCT[intFila].n_idvta = n_IdGenerado; if (xMiFuncion.StoreEjecutar("vta_ventasoct_insertar", l_DetOCT[intFila], mysConec, null) == false) { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } // PARA OTROS DATOS DE LA FACTURA for (intFila = 0; intFila <= l_DetDat.Count - 1; intFila++) { l_DetDat[intFila].n_idvta = n_IdGenerado; if (xMiFuncion.StoreEjecutar("vta_ventasdat_insertar", l_DetDat[intFila], mysConec, null) == false) { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } if (b_GENERARASIENTO == true) { funCon.b_DesdeOtraCapa = true; funCon.mysConec = mysConec; if (funCon.Insertar(l_Diario) == false) { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } e_Movimiento.n_iddocven = n_IdGenerado; } else { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } // ACTUALIZAMOS EL MOVIMIENTO EN LA TABLA MOVIMIENTOS DEL MODULO DE ESTACIONAMIENTO if (xMiFuncion.StoreEjecutar("est_movimientos_actualizar", e_Movimiento, mysConec, null) == true) { int n_row = 0; for (n_row = 0; n_row <= l_movdet.Count - 1; n_row++) { l_movdet[n_row].n_idmov = e_Movimiento.n_id; booOk = xMiFuncion.StoreEjecutar("est_movimientosdet_insertar", l_movdet[n_row], mysConec, null); if (booOk == false) { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } } } else { b_OcurrioError = xMiFuncion.booOcurrioError; c_ErrorMensaje = xMiFuncion.StrErrorMensaje; n_ErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } booOk = true; trans.Commit(); return(booOk); } catch (Exception exc) { // SI SUCEDE UN ERROR DEVOLVEMOS FALSO b_OcurrioError = true; c_ErrorMensaje = exc.Message.ToString(); n_ErrorNumber = exc.HResult; trans.Rollback(); return(booOk); } }