public static bool RegistrarLiquidacion001Factura(TipoLiquidacion001Factura Factura) { bool blnRespuesta = false; SqlConnection sqlConexion = new SqlConnection(CotizacionICRL.strCadenaConexion); string strComando = "INSERT INTO [dbo].[liquidacion001_factura] ([id_flujo],[numero_factura],[fecha_emision],[fecha_entrega],[id_moneda],[monto],[observaciones],[asociada],[tipo_cambio]) VALUES (@id_flujo,@numero_factura,@fecha_emision,@fecha_entrega,@id_moneda,@monto,@observaciones,@asociada,@tipo_cambio)"; SqlCommand sqlComando = new SqlCommand(strComando, sqlConexion); try { sqlComando.Parameters.Add("@id_flujo", System.Data.SqlDbType.Int).Value = Factura.id_flujo; sqlComando.Parameters.Add("@numero_factura", System.Data.SqlDbType.BigInt).Value = Factura.numero_factura; sqlComando.Parameters.Add("@fecha_emision", System.Data.SqlDbType.DateTime).Value = Factura.fecha_emision; sqlComando.Parameters.Add("@fecha_entrega", System.Data.SqlDbType.DateTime).Value = Factura.fecha_entrega; sqlComando.Parameters.Add("@id_moneda", System.Data.SqlDbType.SmallInt).Value = Factura.id_moneda; sqlComando.Parameters.Add("@monto", System.Data.SqlDbType.Float).Value = Factura.monto; sqlComando.Parameters.Add("@observaciones", System.Data.SqlDbType.VarChar, 200).Value = Factura.observaciones; sqlComando.Parameters.Add("@asociada", System.Data.SqlDbType.Bit).Value = Factura.asociada; sqlComando.Parameters.Add("@tipo_cambio", System.Data.SqlDbType.Float).Value = Factura.tipo_cambio; sqlConexion.Open(); sqlComando.ExecuteNonQuery(); sqlComando.Dispose(); blnRespuesta = true; } catch (Exception) { blnRespuesta = false; } finally { sqlConexion.Close(); sqlConexion.Dispose(); } return(blnRespuesta); }
public static TipoTraerLiquidacion001Factura TraerLiquidacion001Factura(int Flujo) { TipoTraerLiquidacion001Factura objRespuesta = new TipoTraerLiquidacion001Factura(); SqlConnection sqlConexion = new SqlConnection(CotizacionICRL.strCadenaConexion); string strComando = "SELECT [id_flujo],[id_factura],[numero_factura],[fecha_emision],[fecha_entrega],[id_moneda],[monto],[observaciones],[asociada],[tipo_cambio] FROM [dbo].[liquidacion001_factura] WHERE [id_flujo] = @id_flujo"; SqlCommand sqlComando = new SqlCommand(strComando, sqlConexion); SqlDataReader sqlDatos; SqlDataAdapter sqlAdaptador = new SqlDataAdapter(strComando, sqlConexion); TipoLiquidacion001Factura tdpFila; try { sqlComando.Parameters.Add("@id_flujo", System.Data.SqlDbType.Int).Value = Flujo; sqlConexion.Open(); sqlDatos = sqlComando.ExecuteReader(); while (sqlDatos.Read()) { tdpFila = new TipoLiquidacion001Factura(); tdpFila.id_flujo = Flujo; if (sqlDatos["id_factura"] != DBNull.Value) { tdpFila.id_factura = Convert.ToInt64(sqlDatos["id_factura"]); } if (sqlDatos["numero_factura"] != DBNull.Value) { tdpFila.numero_factura = Convert.ToInt64(sqlDatos["numero_factura"]); } if (sqlDatos["fecha_emision"] != DBNull.Value) { tdpFila.fecha_emision = Convert.ToDateTime(sqlDatos["fecha_emision"]); } if (sqlDatos["fecha_entrega"] != DBNull.Value) { tdpFila.fecha_entrega = Convert.ToDateTime(sqlDatos["fecha_entrega"]); } if (sqlDatos["id_moneda"] != DBNull.Value) { tdpFila.id_moneda = Convert.ToInt16(sqlDatos["id_moneda"]); } if (sqlDatos["monto"] != DBNull.Value) { tdpFila.monto = Convert.ToDouble(sqlDatos["monto"]); } if (sqlDatos["observaciones"] != DBNull.Value) { tdpFila.observaciones = Convert.ToString(sqlDatos["observaciones"]); } if (sqlDatos["asociada"] != DBNull.Value) { tdpFila.asociada = Convert.ToBoolean(sqlDatos["asociada"]); } if (sqlDatos["tipo_cambio"] != DBNull.Value) { tdpFila.tipo_cambio = Convert.ToDouble(sqlDatos["tipo_cambio"]); } objRespuesta.Facturas.Add(tdpFila); } sqlDatos.Close(); sqlComando.Dispose(); sqlAdaptador.SelectCommand.Parameters.Add("@id_flujo", System.Data.SqlDbType.Int).Value = Flujo; sqlAdaptador.Fill(objRespuesta.dsFacturas); objRespuesta.correcto = true; } catch (Exception ex) { objRespuesta.correcto = false; objRespuesta.mensaje = "No se pudo traer el detalle de las facturas debido a: " + ex.Message; } finally { sqlConexion.Close(); sqlConexion.Dispose(); } return(objRespuesta); }