Example #1
0
        private void tlbMenu_PrintClick()
        {
            try
            {
                Cursor = Cursors.WaitCursor;

                List <ReporteProgramProductionBE> lstReporte = null;
                lstReporte = new ReporteProgramProductionBL().Listado(int.Parse(gvProgramProduction.GetFocusedRowCellValue("IdProgramProduction").ToString()));

                if (lstReporte != null)
                {
                    if (lstReporte.Count > 0)
                    {
                        RptVistaReportes objRptProgramProduction = new RptVistaReportes();
                        objRptProgramProduction.VerRptProgramProduction(lstReporte);
                        objRptProgramProduction.ShowDialog();
                    }
                    else
                    {
                        XtraMessageBox.Show("No hay información para el periodo seleccionado", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnInforme_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;

                List <ReporteProgramProductionBE> lstReporte = null;

                if (chkClient.Checked && chkVendor.Checked)
                {
                    lstReporte = new ReporteProgramProductionBL().ListadoFecha(Parametros.intEmpresaId, Convert.ToInt32(cboClient.EditValue), Convert.ToInt32(cboVendor.EditValue), Convert.ToDateTime(deDateFrom.DateTime.ToShortDateString()), Convert.ToDateTime(deDateTo.DateTime.ToShortDateString()));
                    if (lstReporte != null)
                    {
                        if (lstReporte.Count > 0)
                        {
                            RptVistaReportes objRptEpp = new RptVistaReportes();
                            objRptEpp.VerRptProgramProductionDate(lstReporte, deDateFrom.DateTime.ToShortDateString(), deDateTo.DateTime.ToShortDateString());
                            objRptEpp.ShowDialog();
                        }
                        else
                        {
                            XtraMessageBox.Show("No hay información para el periodo seleccionado", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    Cursor = Cursors.Default;

                    return;
                }

                if (chkClient.Checked)
                {
                    lstReporte = new ReporteProgramProductionBL().ListadoFecha(Parametros.intEmpresaId, Convert.ToInt32(cboClient.EditValue), 0, Convert.ToDateTime(deDateFrom.DateTime.ToShortDateString()), Convert.ToDateTime(deDateTo.DateTime.ToShortDateString()));
                    if (lstReporte != null)
                    {
                        if (lstReporte.Count > 0)
                        {
                            RptVistaReportes objRptEpp = new RptVistaReportes();
                            objRptEpp.VerRptProgramProductionDate(lstReporte, deDateFrom.DateTime.ToShortDateString(), deDateTo.DateTime.ToShortDateString());
                            objRptEpp.ShowDialog();
                        }
                        else
                        {
                            XtraMessageBox.Show("No hay información para el periodo seleccionado", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    Cursor = Cursors.Default;

                    return;
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        void ExportarExcel(string filename)
        {
            Excel._Application xlApp;
            Excel._Workbook    xlLibro;
            Excel._Worksheet   xlHoja;
            Excel.Sheets       xlHojas;
            xlApp    = new Excel.Application();
            filename = Path.Combine(Directory.GetCurrentDirectory(), "Excel\\ProductionProgramClient.xlsx");
            xlLibro  = xlApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            xlHojas  = xlLibro.Sheets;
            xlHoja   = (Excel._Worksheet)xlHojas[1];

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                int Row       = 6;
                int Secuencia = 1;

                List <ReporteProgramProductionBE> lstReporteProgramProduction = null;
                lstReporteProgramProduction = new ReporteProgramProductionBL().ListadoClient(Parametros.intEmpresaId, Convert.ToInt32(cboClient.EditValue), Convert.ToInt32(txtPeriodo.EditValue));
                if (lstReporteProgramProduction.Count > 0)
                {
                    string strTitulo = "";
                    strTitulo = "SUMMARY PROG PROD " + cboClient.Text.ToString() + " " + txtPeriodo.Text.ToString();

                    xlHoja.Cells[2, 1] = strTitulo;

                    decimal  decComision = 0;
                    ClientBE objE_Client = null;
                    objE_Client = new ClientBL().Selecciona(Convert.ToInt32(cboClient.EditValue));
                    if (objE_Client != null)
                    {
                        decComision = objE_Client.PercentComision1;
                    }

                    xlHoja.Shapes.AddPicture(Path.Combine(Directory.GetCurrentDirectory(), "Logo.jpg"), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 1, 1, 100, 60);

                    foreach (var item in lstReporteProgramProduction)
                    {
                        xlHoja.Cells[Row, 2] = item.TotalUnits;
                        xlHoja.Cells[Row, 3] = item.TotalFob;
                        xlHoja.Cells[Row, 4] = decComision;

                        Row       = Row + 1;
                        Secuencia = Secuencia + 1;
                    }
                }

                xlLibro.SaveAs("C:\\Excel\\ProductionProgramClient.xlsx", Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

                xlLibro.Close(true, Missing.Value, Missing.Value);
                xlApp.Quit();

                Cursor.Current = Cursors.Default;
                BSUtils.OpenExcel("C:\\Excel\\ProductionProgramClient.xlsx");
                //XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\Classification.xlsx", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                xlLibro.Close(false, Missing.Value, Missing.Value);
                xlApp.Quit();
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }