Esempio n. 1
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                if (DtpFechaIni.Value != null & DtpFechaFin.Value != null & CboSede.SelectedIndex != -1 & c1cboCia.SelectedIndex != -1 & CboProducto.SelectedIndex != -1)
                {
                    ProductoID    = CboProducto.SelectedValue.ToString();
                    Fecinicio     = Convert.ToDateTime(DtpFechaIni.Value.ToShortDateString());
                    FecFin        = Convert.ToDateTime(DtpFechaFin.Value.ToShortDateString());
                    EmpresaID     = c1cboCia.SelectedValue.ToString();
                    SedeID        = CboSede.SelectedValue.ToString();
                    Empresa       = c1cboCia.Columns["NomEmpresa"].Value.ToString();
                    NomSede       = CboSede.Columns["NomSede"].Value.ToString();
                    DtComprobante = ObjCL_Venta.GetVentasPorProducto(Fecinicio, FecFin, EmpresaID, SedeID, ProductoID);
                    ObjCrGetVentasPorProducto.SetDataSource(DtComprobante);

                    CrvVentasSede.ReportSource = ObjCrGetVentasPorProducto;
                    //pasar datos directo al crystal reports
                    TextObject txt;
                    txt      = (TextObject)ObjCrGetVentasPorProducto.ReportDefinition.ReportObjects["TxtTitulo1"];
                    txt.Text = "EMPRESA: " + Empresa + ". SEDE: " + NomSede;

                    TextObject txt2;
                    txt2      = (TextObject)ObjCrGetVentasPorProducto.ReportDefinition.ReportObjects["TxtTitulo"];
                    txt2.Text = "PRODUCTO: " + CboProducto.SelectedValue.ToString() + " - " + CboProducto.Columns["Alias"].Value.ToString();
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.InnerException.Message);
                MessageBox.Show(ex.Message);
            }

            Cursor = Cursors.Default;
        }