예제 #1
0
        private void repReportOption_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            // --- save partial or final report
            if (e.Button.Index == 0)
            {
                // --- report data
                #region save report

                bool result_report = false;

                CRecep_sample_report oRecep_sample_report = new CRecep_sample_report();
                CRecep_sample_reportFactory faRecep_sample_report = new CRecep_sample_reportFactory();
                Reception oReception = new Reception();

                oRecep_sample_report = faRecep_sample_report.GetByPrimaryKey(
                    new CRecep_sample_reportKeys(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report))));

                short report_status = Convert.ToInt16(gvReport.GetFocusedRowCellValue(gcRep_report_status));

                // si es un reporte en creación poner como reservado
                if (report_status == Convert.ToInt16(Comun.ReportStatus.EnCreacion)) // --- creacion
                {
                    oRecep_sample_report = new CRecep_sample_report();
                    gvReport.SetFocusedRowCellValue(gcRep_report_status, Convert.ToInt16(Comun.ReportStatus.Reportado));
                    oRecep_sample_report.Idrecep_sample = oRecep_sample.Idrecep_sample;
                    oRecep_sample_report.Idrecep_sample_report = Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report));
                    oRecep_sample_report.Order_report = Convert.ToInt16(gvReport.GetFocusedRowCellValue(gcRep_order_report));
                    oRecep_sample_report.Report_status = Convert.ToInt16(Comun.ReportStatus.Reportado);
                    oRecep_sample_report.Type_report = Convert.ToInt16(gvReport.GetFocusedRowCellValue(gcRep_type_report));      // --- 1:parcial, 2:final
                    oRecep_sample_report.Cod_recep_sample_report = oReception.GetNewCodReport(Convert.ToInt16(gvReport.GetFocusedRowCellValue(gcRep_type_report)));
                    oRecep_sample_report.Date_report = DateTime.Now;
                    oRecep_sample_report.Time_report = DateTime.Now;

                    result_report = faRecep_sample_report.Insert(oRecep_sample_report);

                    gvReport.SetFocusedRowCellValue(gcRep_idrecep_sample_report, oRecep_sample_report.Idrecep_sample_report);
                    gvReport.SetFocusedRowCellValue(gcRep_cod_recep_sample_report, oRecep_sample_report.Cod_recep_sample_report);
                    gvReport.SetFocusedRowCellValue(gcRep_Str_cod_recep_sample_report, oReception.GetFormatReportCode(oRecep_sample_report.Type_report, oRecep_sample_report.Cod_recep_sample_report));

                    if (result_report)
                    {
                        // --- create the partial report
                        List<CPositionValue> lstPositionValue = new List<CPositionValue>();

                        foreach (GridCell[] cells in lstItemsSelReport)
                        {
                            foreach (GridCell cell in cells)
                            {
                                CTagInfoMethod tagMethod = (CTagInfoMethod)cell.Column.Tag;

                                int idtemplate_method = tagMethod.IDTemplate_method;
                                long idrecep_sample_detail = Convert.ToInt64(gvReception.GetRowCellValue(cell.RowHandle, gcRec_idrecep_sample_detail));
                                long idrecep_sample_report = oRecep_sample_report.Idrecep_sample_report;

                                CPositionValue position = GetObjectPosition(idrecep_sample_detail, tagMethod.IDTemplate_method);
                                CCells_reportedFactory faCells_reported = new CCells_reportedFactory();
                                CCells_reported oCell_reported = new CCells_reported();

                                oCell_reported.Idtemplate_method = idtemplate_method;
                                oCell_reported.Idrecep_sample_detail = idrecep_sample_detail;
                                oCell_reported.Idrecep_sample_report = idrecep_sample_report;
                                oCell_reported.Idrecep_sample_detail_elem = position.idrecep_sample_detail_elem;

                                bool result_cell_reported = false;

                                if (!(result_cell_reported = faCells_reported.Update(oCell_reported)))
                                    result_cell_reported = faCells_reported.Insert(oCell_reported);

                                if (result_cell_reported)
                                {
                                    position.idrecep_sample_report = idrecep_sample_report;
                                    position.row = cell.RowHandle;
                                    position.col = cell.Column;
                                    position.idcell_reported = oCell_reported.Idcell_reported;
                                    if (oRecep_sample_report.Type_report == 1)
                                        position.color = Partial_report_color;
                                    else
                                        position.color = Final_report_color;

                                    if (!lstPositionValue.Exists(c => c.idrecep_sample_detail_elem == position.idrecep_sample_detail_elem))
                                        lstPositionValue.Add(position);
                                }
                            }
                        }
                        lstItemsSelReport.Clear();
                        DicCellsSavedReport.Add(Convert.ToInt16(oRecep_sample_report.Order_report), lstPositionValue);
                        GetUnreportData(oRecep_sample.Idrecep_sample);
                    }
                }

                #endregion

                lstItemsSelReport.Clear();
                gvReception.Focus();
            }
            else if (e.Button.Index == 1)
            {
                // --- INFORME DE ENSAYO LAS-13-01299
                CReportTestFactory faReportTest = new CReportTestFactory();

                DataTable dtResults = faReportTest.GetReportResults(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report)));
                DataTable dtHead = faReportTest.GetReportHead(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report)));
                DataTable dtMethods = faReportTest.GetReportMethods(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report)));

                oFastReportMethods.AddParameter("Attention", GetContactAttention(oRecep_sample.Idrecep_sample));
                oFastReportMethods.AddParameter("Cod_report", gvReport.GetFocusedRowCellValue(gcRep_Str_cod_recep_sample_report).ToString());
                oFastReportMethods.AddParameter("Date_report", Convert.ToDateTime(gvReport.GetFocusedRowCellValue(gcRep_Date_report)));
                oFastReportMethods.ReportName = "ReportTest.frx";
                oFastReportMethods.RegisterDataTable(dtHead, "Head");
                oFastReportMethods.RegisterDataTable(dtMethods, "Methods");
                oFastReportMethods.RegisterDataTable(dtResults, "Results");

                oFastReportMethods.ShowPreviewReport();
            }
            else if (e.Button.Index == 2)
            {
                CReportTestFactory faReportTest = new CReportTestFactory();
                DataTable dtResults = faReportTest.GetReportResults(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report)));
                DataTable dtHead = faReportTest.GetReportHead(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report)));
                DataTable dtMethods = faReportTest.GetReportMethods(Convert.ToInt64(gvReport.GetFocusedRowCellValue(gcRep_idrecep_sample_report)));

                oFastReportMethods.AddParameter("Attention", GetContactAttention(oRecep_sample.Idrecep_sample));
                oFastReportMethods.AddParameter("Cod_report", gvReport.GetFocusedRowCellValue(gcRep_Str_cod_recep_sample_report).ToString());
                oFastReportMethods.AddParameter("Date_report", Convert.ToDateTime(gvReport.GetFocusedRowCellValue(gcRep_Date_report)));
                oFastReportMethods.ReportName = "ReportTest.frx";
                oFastReportMethods.RegisterDataTable(dtHead, "Head");
                oFastReportMethods.RegisterDataTable(dtMethods, "Methods");
                oFastReportMethods.RegisterDataTable(dtResults, "Results");

                oFastReportMethods.DesignReport();
            }
        }