public bool Insertar(BE_ALM_MOVIMIENTOS entMovimientos, List <BE_ALM_MOVIMIENTOSDET> entDetalle) { bool booResult = false; DatosAcces objFunAcc = new DatosAcces(); string c_Sql; bool b_tipmov = false; int n_tipdoc = 0; int n_tipope = 0; try { if (entMovimientos.n_idtipmov == 1) { b_tipmov = true; } else { b_tipmov = false; } if (entMovimientos.n_idtipope == 10) { n_tipope = 4; } // SALIDA A PRODUCCIÓN if (entMovimientos.n_idtipope == 2) { n_tipope = 1; } // COMPRA NACIONAL if (entMovimientos.n_idtipope == 19) { n_tipope = 3; } // ENTRADA DE PRODUCCIÓN if (entMovimientos.n_idtipope == 30) { n_tipope = 2; } // SALIDA DE BIENES EN PRÉSTAMO if (entMovimientos.n_idtipdoc == 50) { n_tipdoc = 112; } // NOTA DE SALIDA EN AMBAS VERSIONES if (entMovimientos.n_idtipdoc == 49) { n_tipdoc = 113; } // NOTA DE INGRESO EN AMBAS VERSIONES if (entMovimientos.n_idtipdoc == 10) { n_tipdoc = 9; } // GUIA DE REMISION EN AMBAS VERSIONES // ARMANOS LA CADENA SQL PARA ACTUALIZAR ACCES c_Sql = "INSERT INTO alm_ingreso ( " + " id, " + " fching, " + " idpro, " + " fchdoc, " + " numser, " + " numdoc, " + " tipmov, " + " idalm, " + " ano, " + " idmes, " + " nombre, " + " tipdoc, " + " idope " + " ) VALUES " + " ( " + " " + entMovimientos.n_id + ", " + " cDate('" + entMovimientos.d_fching.ToString("dd/MM/yyyy") + "'), " + " " + entMovimientos.n_idclipro + ", " + " Cdate('" + entMovimientos.d_fchdoc.ToString("dd/MM/yyyy") + "'), " + " '" + entMovimientos.c_numser + "', " + " '" + entMovimientos.c_numdoc + "', " + " " + b_tipmov + ", " + " " + entMovimientos.n_idalm + ", " + " " + entMovimientos.n_anotra + ", " + " " + entMovimientos.n_idmes + ", " + " '" + c_NomSolicitante + "'," + " " + n_tipdoc + "," + " " + n_tipope + "" + " ) "; booResult = objFunAcc.EjecutarSQL(c_Sql, AccConec); foreach (BE_ALM_MOVIMIENTOSDET_CONSULTA element in entDetalle) { string c_newhoring = "Null"; string c_newhorsal = "Null"; if (element.h_horsal != "") { c_newhorsal = "'" + element.h_horsal + "'"; } if (element.h_horing != "") { c_newhoring = "'" + element.h_horing + "'"; } c_Sql = "INSERT INTO alm_ingresodet ( " + " iding, " + " iditem, " + " cantidad, " + " revisado, " + " c_numlot, " + " h_horsal, " + " h_horing " + " ) VALUES " + " ( " + " " + entMovimientos.n_id + ", " + " " + element.n_idite + ", " + " " + element.n_can + ", " + " " + false + ", " + " '" + element.c_numlot + "', " + " " + c_newhorsal + ", " + " " + c_newhoring + " " + " ) "; booResult = objFunAcc.EjecutarSQL(c_Sql, AccConec); if (booResult == false) { booOcurrioError = objFunAcc.booOcurrioError; StrErrorMensaje = objFunAcc.StrErrorMensaje; IntErrorNumber = objFunAcc.IntErrorNumber; return(booResult); } } return(booResult); } catch (Exception exc) { // SI SUCEDE UN ERROR DEVOLVEMOS FALSO booOcurrioError = objFunAcc.booOcurrioError; StrErrorMensaje = objFunAcc.StrErrorMensaje; IntErrorNumber = objFunAcc.IntErrorNumber; return(booResult); } }
public bool Insertar_off(BE_ALM_MOVIMIENTOS entCabecera, List <BE_ALM_MOVIMIENTOSDET> lstDetalle, List <BE_ALM_INVENTARIOLOTE> lstLote) { bool booOk = false; int intFila = 0; DatosMySql xMiFuncion = new DatosMySql(); xMiFuncion.ReAbrirConeccion(mysConec); try { if (xMiFuncion.StoreEjecutar("alm_movimientos_insertar", entCabecera, mysConec, 0) == true) { for (intFila = 0; intFila <= lstDetalle.Count - 1; intFila++) { entCabecera.n_id = Convert.ToInt32(xMiFuncion.intIdGenerado); lstDetalle[intFila].n_idmov = Convert.ToInt32(xMiFuncion.intIdGenerado); if (xMiFuncion.StoreEjecutar("alm_movimientosdet_insertar", lstDetalle[intFila], mysConec, null) == true) { booOk = true; } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; booOk = false; return(booOk); } // AGREGAMOS LOS LOTES lstLote[intFila].n_iddocmov = Convert.ToInt32(xMiFuncion.intIdGenerado); if (xMiFuncion.StoreEjecutar("alm_inventariolotes_insertar", lstLote[intFila], mysConec, null) == true) { booOk = true; } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; booOk = false; return(booOk); } } } else { booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; booOk = false; return(booOk); } return(booOk); } catch (Exception exc) { // SI SUCEDE UN ERROR DEVOLVEMOS FALSO booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; return(booOk); } }
public bool Actualizar(BE_ALM_MOVIMIENTOS entCabecera, List <BE_ALM_MOVIMIENTOSDET> lstDetalle, List <BE_ALM_INVENTARIOLOTE> lstLote) { bool booOk = false; int intFila = 0; DatosMySql xMiFuncion = new DatosMySql(); MySqlTransaction trans; xMiFuncion.ReAbrirConeccion(mysConec); trans = mysConec.BeginTransaction(); try { if (xMiFuncion.StoreEjecutar("alm_movimientos_actualizar", entCabecera, mysConec, null) == true) { // ELIMINAMOS LOS ITEMS PREVIOS string[,] arrParametrosLote = new string[2, 3] { { "n_idemp", "System.INT64", entCabecera.n_idemp.ToString() }, { "n_iddocmov", "System.INT64", entCabecera.n_id.ToString() } }; // BORRAMOS EL MOVIMIENTOS DE LOS LOTES if (xMiFuncion.StoreEjecutar("alm_inventariolotes_delete", arrParametrosLote, mysConec) == true) { string[,] arrParametros = new string[1, 3] { { "n_id", "System.INT64", entCabecera.n_id.ToString() } }; // BORRAMOS EL DETALLE if (xMiFuncion.StoreEjecutar("alm_movimientosdet_delete", arrParametros, mysConec) == true) { // SI LOS ITEMS SE ELIMINARON CON EXITO INSERTAMOS LOS NUEVOS ITEMS for (intFila = 0; intFila <= lstDetalle.Count - 1; intFila++) { //lstDetalle[intFila].n_idmov = Convert.ToInt32(xMiFuncion.intIdGenerado); if (xMiFuncion.StoreEjecutar("alm_movimientosdet_insertar", lstDetalle[intFila], mysConec, null) == true) { booOk = true; } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); booOk = false; return(booOk); } // AGREGAMOS LOS LOTES //lstLote[intFila].n_iddocmov = Convert.ToInt32(xMiFuncion.intIdGenerado); if (xMiFuncion.StoreEjecutar("alm_inventariolotes_insertar", lstLote[intFila], mysConec, null) == true) { booOk = true; } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); booOk = false; return(booOk); } } } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); booOk = false; return(booOk); } } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); booOk = false; return(booOk); } } else { // CONTROLAR EL ERROR booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); booOk = false; return(booOk); } booOk = true; trans.Commit(); return(booOk); } catch (Exception exc) { // SI SUCEDE UN ERROR DEVOLVEMOS FALSO booOcurrioError = xMiFuncion.booOcurrioError; StrErrorMensaje = xMiFuncion.StrErrorMensaje; IntErrorNumber = xMiFuncion.IntErrorNumber; trans.Rollback(); return(booOk); } }
public bool InsertarMovimiento(BE_ALM_TRANSFERENCIAS entTransferencia, int n_TipoMovimiento) { bool booOk = false; BE_ALM_MOVIMIENTOS entCabecera = new BE_ALM_MOVIMIENTOS(); List <BE_ALM_MOVIMIENTOSDET> lstDetalle = new List <BE_ALM_MOVIMIENTOSDET>(); List <BE_ALM_INVENTARIOLOTE> lstLote = new List <BE_ALM_INVENTARIOLOTE>(); CD_alm_movimientos miFun = new CD_alm_movimientos(); miFun.mysConec = mysConec; int n_idtipdocingmov = 49; int n_idtipdocsalmov = 50; int n_idtipdocrefmov = 95; int n_idtipopeingmov = 21; int n_idtipopesalmov = 11; CD_sun_tipdoccom miFun_sun_tipdoccom = new CD_sun_tipdoccom(); miFun_sun_tipdoccom.mysConec = mysConec; string c_numdocmov = string.Empty; if (n_TipoMovimiento == 1) { c_numdocmov = miFun_sun_tipdoccom.UltimoNumero(entTransferencia.n_idemp , n_idtipdocingmov , entTransferencia.c_numser); } else { c_numdocmov = miFun_sun_tipdoccom.UltimoNumero(entTransferencia.n_idemp , n_idtipopesalmov , entTransferencia.c_numser); } entCabecera.n_id = entTransferencia.n_id; entCabecera.n_idemp = entTransferencia.n_idemp; entCabecera.n_idtipmov = n_TipoMovimiento; entCabecera.n_idclipro = 7032; entCabecera.d_fchdoc = entTransferencia.d_fchdoc; entCabecera.d_fching = entTransferencia.d_fching; if (n_TipoMovimiento == 1) { entCabecera.n_idtipdoc = n_idtipdocingmov; } else { entCabecera.n_idtipdoc = n_idtipdocsalmov; } entCabecera.c_numser = entTransferencia.c_numser; entCabecera.c_numdoc = c_numdocmov; if (n_TipoMovimiento == 1) { entCabecera.n_idalm = entTransferencia.n_idalmdest; } else { entCabecera.n_idalm = entTransferencia.n_idalmorig; } entCabecera.n_anotra = entTransferencia.n_anotra; entCabecera.n_idmes = entTransferencia.n_idmes; entCabecera.c_obs = entTransferencia.c_obs; if (n_TipoMovimiento == 1) { entCabecera.n_idtipope = n_idtipopeingmov; } else { entCabecera.n_idtipope = n_idtipopesalmov; } entCabecera.n_tipite = 2; entCabecera.n_docrefidtipdoc = n_idtipdocrefmov; entCabecera.c_docrefnumser = entTransferencia.c_numser; entCabecera.c_docrefnumdoc = entTransferencia.c_numdoc; entCabecera.n_docrefiddocref = entTransferencia.n_id; entCabecera.n_perid = entTransferencia.n_idresp; foreach (BE_ALM_TRANSFERENCIASDET element in entTransferencia.lst_items) { BE_ALM_MOVIMIENTOSDET_CONSULTA entNewDetalle = new BE_ALM_MOVIMIENTOSDET_CONSULTA(); BE_ALM_INVENTARIOLOTE entNewLote = new BE_ALM_INVENTARIOLOTE(); entNewDetalle.n_idmov = entTransferencia.n_id; entNewDetalle.n_idite = element.n_idite; entNewDetalle.n_idpre = element.n_idpre; entNewDetalle.n_can = element.n_can; entNewDetalle.n_idalm = element.n_idalm; entNewDetalle.c_numlot = element.c_numlot; entNewDetalle.n_idtippro = element.n_idtippro; entNewDetalle.d_fchpro = null; entNewDetalle.d_fchven = null; entNewDetalle.n_iddep = element.n_iddep; entNewDetalle.n_idpro = element.n_idpro; entNewDetalle.n_iddis = element.n_iddis; entNewDetalle.c_desori = element.c_desori; entNewDetalle.c_marca = element.c_marca; entNewDetalle.n_preuni = element.n_preuni; entNewDetalle.n_pretot = element.n_pretot; entNewDetalle.h_horing = ""; entNewDetalle.h_horsal = element.h_horsal; entNewDetalle.n_estpro = 1; lstDetalle.Add(entNewDetalle); // AGREGAMOS LOS LOTES entNewLote.n_idemp = entTransferencia.n_idemp; entNewLote.n_idite = element.n_idite; entNewLote.n_iddocmov = 0; entNewLote.d_fchmov = entTransferencia.d_fching; entNewLote.c_numlot = element.c_numlot; entNewLote.n_idunimed = 0; entNewLote.n_caning = 0; entNewLote.n_cansal = 0; if (entCabecera.n_idtipmov == 1) { entNewLote.n_caning = element.n_can; } if (entCabecera.n_idtipmov == 2) { entNewLote.n_cansal = element.n_can; } entNewDetalle.d_fchven = null; entNewLote.n_iddep = element.n_iddep; entNewLote.n_idpro = element.n_idpro; entNewLote.n_iddis = element.n_iddis; entNewLote.c_oriite = element.c_desori; entNewLote.h_horing = ""; entNewLote.h_horsal = element.h_horsal; entNewLote.n_estpro = element.n_estpro; lstLote.Add(entNewLote); } if (miFun.Insertar_off(entCabecera, lstDetalle, lstLote) == false) { booOcurrioError = miFun.booOcurrioError; StrErrorMensaje = miFun.StrErrorMensaje; IntErrorNumber = miFun.IntErrorNumber; return(booOk); } booOk = true; return(booOk); }