public bool Insert_DetalleControlPresupuestal(DetalleControlPresupuestal_VO pDetalleControlPresupuestal, SqlTransaction TransDetalleControlPresupuestal) { bool b_DetalleControlPresupuestal; try { SqlCommand cmdComand = new SqlCommand("USP_I_SICOP_DETALLECONTROLPRESUPUESTAL"); cmdComand.CommandType = System.Data.CommandType.StoredProcedure; cmdComand.Connection = TransDetalleControlPresupuestal.Connection; cmdComand.Transaction = TransDetalleControlPresupuestal; cmdComand.Parameters.Clear(); cmdComand.Parameters.AddWithValue("@CPRE_INT_IDCONTROLPRESUPUESTAL", pDetalleControlPresupuestal.CPRE_INT_IDCONTROLPRESUPUESTAL); cmdComand.Parameters.AddWithValue("@EGAS_VCH_IDESPECIFICADEGASTO", pDetalleControlPresupuestal.EGAS_VCH_IDESPECIFICADEGASTO); cmdComand.Parameters.AddWithValue("@META_VCH_IDMETA", pDetalleControlPresupuestal.META_VCH_IDMETA); cmdComand.Parameters.AddWithValue("@DCPR_DEC_IMPORTE", pDetalleControlPresupuestal.DCPR_DEC_IMPORTE); b_DetalleControlPresupuestal = cmdComand.ExecuteNonQuery() > 0; } catch (Exception e) { if (e.Source != null) Console.WriteLine("IOException source: {0}", e.Source); throw; } return b_DetalleControlPresupuestal; }
public bool Update_ControlPresupuestal(ControlPresupuestal_VO pControlPresupuestal, DataTable DtDetalleControlPresupuestal) { SqlConnection sqlConection = null; SqlTransaction TransControlPresupuestal = null; bool b_ControlPresupuestal = false; bool b_DetalleControlP = false; bool b_DeleteDetalleControlP = false; try { sqlConection = new SqlConnection(BEConexion.vg_strCadenaConexion); sqlConection.Open(); TransControlPresupuestal = sqlConection.BeginTransaction(); if (pControlPresupuestal != null) { b_DeleteDetalleControlP = new DetalleControlPresupuestal_DAL().Delete_DetalleControlPresupuestal(pControlPresupuestal, TransControlPresupuestal); if (b_DeleteDetalleControlP) { b_ControlPresupuestal = new ControlPresupuestal_DAL().Update_ControlPresupuestal(pControlPresupuestal, TransControlPresupuestal); if (b_ControlPresupuestal) { int intDetalleCount = 0; foreach (DataRow dtRow in DtDetalleControlPresupuestal.Rows) { DetalleControlPresupuestal_VO pDetalleControlPresupuestal = new DetalleControlPresupuestal_VO(); pDetalleControlPresupuestal.CPRE_INT_IDCONTROLPRESUPUESTAL = pControlPresupuestal.CPRE_INT_IDCONTROLPRESUPUESTAL; pDetalleControlPresupuestal.EGAS_VCH_IDESPECIFICADEGASTO = pControlPresupuestal.EGAS_VCH_IDESPECIFICADEGASTO; pDetalleControlPresupuestal.DCPR_DEC_IMPORTE = Convert.ToDecimal(dtRow["DCPR_DEC_IMPORTE"]); pDetalleControlPresupuestal.META_VCH_IDMETA = dtRow["META_VCH_IDMETA"].ToString(); if (new DetalleControlPresupuestal_DAL().Insert_DetalleControlPresupuestal(pDetalleControlPresupuestal, TransControlPresupuestal)) { intDetalleCount++; } } b_DetalleControlP = (intDetalleCount == DtDetalleControlPresupuestal.Rows.Count); } } } if (b_ControlPresupuestal && b_DetalleControlP && b_DeleteDetalleControlP) { TransControlPresupuestal.Commit(); } else { TransControlPresupuestal.Rollback(); } } catch (Exception exception) { if (TransControlPresupuestal != null) TransControlPresupuestal.Rollback(); return false; } finally { if (sqlConection != null) { sqlConection.Close(); } sqlConection.Dispose(); } return b_ControlPresupuestal; }