private void btnImprimirLote_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet dsRenovacion = new DataSet();
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexionStrDBEfideFactoring"].ConnectionString))
                {
                    SqlCommand cmd1 = new SqlCommand("Rpt_Renovacion", con);
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.AddWithValue("@Opcion", 1);
                    cmd1.Parameters.AddWithValue("@IdRenovacion", txtIdRenovacion.Text.Trim());
                    SqlDataAdapter daCab = new SqlDataAdapter(cmd1);
                    daCab.Fill(dsRenovacion, "Renovacion");

                    SqlCommand cmd2 = new SqlCommand("Rpt_Renovacion", con);
                    cmd2.CommandType = CommandType.StoredProcedure;
                    cmd2.Parameters.AddWithValue("@Opcion", 2);
                    cmd2.Parameters.AddWithValue("@IdRenovacion", txtIdRenovacion.Text.Trim());
                    SqlDataAdapter daCab2 = new SqlDataAdapter(cmd2);
                    daCab2.Fill(dsRenovacion, "RenovacionDet1");

                    SqlCommand cmd3 = new SqlCommand("Rpt_Renovacion", con);
                    cmd3.CommandType = CommandType.StoredProcedure;
                    cmd3.Parameters.AddWithValue("@Opcion", 3);
                    cmd3.Parameters.AddWithValue("@IdRenovacion", txtIdRenovacion.Text.Trim());
                    SqlDataAdapter daCab3 = new SqlDataAdapter(cmd3);
                    daCab3.Fill(dsRenovacion, "RenovacionDet2");
                    con.Close();
                }

                Crystal.crRptRenovacion          ocrRptRenovacion         = new Crystal.crRptRenovacion();
                Reportes.frmVisorLoteLiquidacion ofrmVisorLoteLiquidacion = new Reportes.frmVisorLoteLiquidacion();
                ofrmVisorLoteLiquidacion.crvVisorLoteLiq.ReportSource = ocrRptRenovacion;
                ocrRptRenovacion.SetDataSource(dsRenovacion);
                ocrRptRenovacion.SetParameterValue("usuario", General.General.GetUsuario);
                ofrmVisorLoteLiquidacion.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void Imprimir()
        {
            try
            {
                if (gvRenovacion.CurrentRow.Cells["IdEstado_tt"].Value.ToString() == "00113") //Anulada
                {
                    return;
                }

                DataSet dsRenovacion = new DataSet();
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexionStrDBEfideFactoring"].ConnectionString))
                {
                    SqlCommand cmd1 = new SqlCommand("Rpt_Renovacion", con);
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.AddWithValue("@Opcion", 1);
                    cmd1.Parameters.AddWithValue("@IdRenovacion", gvRenovacion.CurrentRow.Cells["IdRenovacion"].Value.ToString());
                    SqlDataAdapter daCab = new SqlDataAdapter(cmd1);
                    daCab.Fill(dsRenovacion, "Renovacion");

                    SqlCommand cmd2 = new SqlCommand("Rpt_Renovacion", con);
                    cmd2.CommandType = CommandType.StoredProcedure;
                    cmd2.Parameters.AddWithValue("@Opcion", 2);
                    cmd2.Parameters.AddWithValue("@IdRenovacion", gvRenovacion.CurrentRow.Cells["IdRenovacion"].Value.ToString());
                    SqlDataAdapter daCab2 = new SqlDataAdapter(cmd2);
                    daCab2.Fill(dsRenovacion, "RenovacionDet1");

                    SqlCommand cmd3 = new SqlCommand("Rpt_Renovacion", con);
                    cmd3.CommandType = CommandType.StoredProcedure;
                    cmd3.Parameters.AddWithValue("@Opcion", 3);
                    cmd3.Parameters.AddWithValue("@IdRenovacion", gvRenovacion.CurrentRow.Cells["IdRenovacion"].Value.ToString());
                    SqlDataAdapter daCab3 = new SqlDataAdapter(cmd3);
                    daCab3.Fill(dsRenovacion, "RenovacionDet2");
                    con.Close();

                    SqlCommand cmd4 = new SqlCommand("Rpt_Renovacion", con);
                    cmd4.CommandType = CommandType.StoredProcedure;
                    cmd4.Parameters.AddWithValue("@Opcion", 4);
                    cmd4.Parameters.AddWithValue("@IdRenovacion", gvRenovacion.CurrentRow.Cells["IdRenovacion"].Value.ToString());
                    SqlDataAdapter daCab4 = new SqlDataAdapter(cmd4);
                    daCab4.Fill(dsRenovacion, "RenovacionPago");
                    con.Close();
                }

                Crystal.crRptRenovacion          ocrRptRenovacion         = new Crystal.crRptRenovacion();
                Reportes.frmVisorLoteLiquidacion ofrmVisorLoteLiquidacion = new Reportes.frmVisorLoteLiquidacion();
                ofrmVisorLoteLiquidacion.crvVisorLoteLiq.ReportSource = ocrRptRenovacion;
                ocrRptRenovacion.SetDataSource(dsRenovacion);
                ocrRptRenovacion.SetParameterValue("usuario", General.General.GetUsuario);
                ofrmVisorLoteLiquidacion.Show();

                //Fondo Garantía
                DataSet dsRenovacionFG = new DataSet();
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConexionStrDBEfideFactoring"].ConnectionString))
                {
                    SqlCommand cmd1 = new SqlCommand("Rpt_Renovacion", con);
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.AddWithValue("@Opcion", 1);
                    cmd1.Parameters.AddWithValue("@IdRenovacion", gvRenovacion.CurrentRow.Cells["IdRenovacion"].Value.ToString());
                    SqlDataAdapter daCab = new SqlDataAdapter(cmd1);
                    daCab.Fill(dsRenovacionFG, "Renovacion");

                    SqlCommand cmd4 = new SqlCommand("Rpt_Renovacion", con);
                    cmd4.CommandType = CommandType.StoredProcedure;
                    cmd4.Parameters.AddWithValue("@Opcion", 5);
                    cmd4.Parameters.AddWithValue("@IdRenovacion", gvRenovacion.CurrentRow.Cells["IdRenovacion"].Value.ToString());
                    SqlDataAdapter daCab4 = new SqlDataAdapter(cmd4);
                    daCab4.Fill(dsRenovacionFG, "RenovacionFG");
                    con.Close();
                }

                if (dsRenovacionFG.Tables["RenovacionFG"].Rows.Count > 0)
                {
                    Crystal.crRptRenovacionFG        ocrRptRenovacionFG = new Crystal.crRptRenovacionFG();
                    Reportes.frmVisorLoteLiquidacion ofrm = new Reportes.frmVisorLoteLiquidacion();
                    ofrm.crvVisorLoteLiq.ReportSource = ocrRptRenovacionFG;
                    ocrRptRenovacionFG.SetDataSource(dsRenovacionFG);
                    ocrRptRenovacionFG.SetParameterValue("Usuario", General.General.GetUsuario);
                    ofrm.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }