Beispiel #1
0
 public CPositionValue GetObjectPosition(long idrecep_sample_detail, int idtemplate_method)
 {
     CPositionValue positionValue = new CPositionValue();
     for (int i = 0; i < DTReceptionDetailElem.Rows.Count; i++)
     {
         if (Convert.ToInt64(DTReceptionDetailElem.Rows[i]["idrecep_sample_detail"]) == idrecep_sample_detail
             && Convert.ToInt32(DTReceptionDetailElem.Rows[i]["idtemplate_method"]) == idtemplate_method)
         {
             positionValue.idtemplate_method = idtemplate_method;
             positionValue.idrecep_sample_detail = idrecep_sample_detail;
             positionValue.idrecep_sample_detail_elem = Convert.ToInt64(DTReceptionDetailElem.Rows[i]["idrecep_sample_detail_elem"]);
         }
     }
     return positionValue;
 }
Beispiel #2
0
        void GetUnreportData(long idrecep_sample)
        {
            /*
            CREATE TEMP TABLE tmp_data_report ON COMMIT DROP AS
            SELECT t1.*
            FROM public.cells_reported t1, recep_sample_report t2
            WHERE t2.idrecep_sample = p_idrecep_sample
                AND t2.report_status = 2;

            return query
            SELECT t1.idrecep_sample_detail_elem, t1.idrecep_sample, t1.idrecep_sample_detail, t1.idelement, t1.idtemplate_method
            FROM recep_sample_detail_elem t1, recep_sample_report t2
            WHERE t1.idrecep_sample = t2.idrecep_sample
                AND t1.idrecep_sample = p_idrecep_sample
                AND idrecep_sample_detail_elem NOT IN (SELECT idrecep_sample_detail_elem
                                    FROM tmp_data_report);
            */

            var query =
                (from m in new CCells_reportedFactory().GetAll()
                 from n in new CRecep_sample_reportFactory().GetAll()
                    .Where(x => x.Idrecep_sample_report == m.Idrecep_sample_report && x.Idrecep_sample == idrecep_sample && x.Report_status == 2)
                 select m).ToList();

            var dtUnreportData =
                (from m in new CRecep_sample_detail_elemFactory().GetAll().Where(x => x.Idrecep_sample == idrecep_sample)
                 from n in new CRecep_sample_reportFactory().GetAll().Where(x => x.Idrecep_sample == m.Idrecep_sample)
                 from p in query
                 where m.Idrecep_sample_detail_elem != p.Idrecep_sample_detail_elem
                 select new
                 {
                     m.Idrecep_sample_detail_elem,
                     m.Idrecep_sample,
                     m.Idrecep_sample_detail,
                     m.Idelement,
                     m.Idtemplate_method
                 }).ToList();

            LstUnreportData.Clear();

            for (int i = 0; i < dtUnreportData.Count; i++)
            {
                long idrecep_sample_detail = Convert.ToInt64(dtUnreportData[i].Idrecep_sample_detail);
                int idtemplate_method = Convert.ToInt32(dtUnreportData[i].Idtemplate_method);
                long idrecep_sample_detail_elem = Convert.ToInt32(dtUnreportData[i].Idrecep_sample_detail_elem);

                Color colorUnreported = Color.LightBlue;

                CPositionValue oPosition = new CPositionValue();

                oPosition.idtemplate_method = idtemplate_method;
                oPosition.idrecep_sample_report = 0;
                oPosition.idrecep_sample_detail = idrecep_sample_detail;
                oPosition.idrecep_sample_detail_elem = idrecep_sample_detail_elem;
                oPosition.idcell_reported = 0;
                oPosition.color = colorUnreported;

                LstUnreportData.Add(oPosition);
            }
        }
Beispiel #3
0
        void RetrieveRegisterReception()
        {
            // --- return date of recep_sample
            DicCellsSavedReport.Clear();
            DicCellsSaveProgram.Clear();

            Reception oReception = new Reception();

            if (oRecep_sample != null)
            {
                tpRightReports.PageVisible = true;
                tpRightAttach.PageVisible = true;
                tpRightProgram.PageVisible = true;

                txIdrecep_sample.Text = oRecep_sample.Idrecep_sample.ToString();
                statusRegReception = StatusRegRecep.reg_recep_saved;
                tbCod_recep_sample.Text = oRecep_sample.Cod_recep_sample;
                deReception.DateTime = Convert.ToDateTime(oRecep_sample.Date_reception);
                deHourReception.EditValue = Convert.ToDateTime(oRecep_sample.Date_reception);
                deResult.DateTime = Convert.ToDateTime(oRecep_sample.Date_result);
                deHourResult.EditValue = Convert.ToDateTime(oRecep_sample.Date_result);
                cbTypeSample.EditValue = oRecep_sample.Cod_type_sample;

                tbNumDays.Value = Convert.ToDecimal(Convert.ToDateTime(oRecep_sample.Date_result).Subtract(Convert.ToDateTime(oRecep_sample.Date_reception)).TotalDays);

                tbSubTotalAmount.Text = oRecep_sample.Total_amount.ToString();
                tbTotalIgv.Text = oRecep_sample.Total_igv.ToString();
                tbTotalAmount.Text = oRecep_sample.Total_amount_igv.ToString();
                tbAmortization.Text = oRecep_sample.Amortization.ToString();

                if (oRecep_sample.Amortization.Value == 0)
                    tbResidue.BackColor = Color.Coral;

                CCompany oCompany = new CCompanyFactory().GetByPrimaryKey(new CCompanyKeys(Convert.ToInt16(oRecep_sample.Idcompany)));

                // --- retrieve dispatch
                CRecep_sample_dispatch oRecep_sample_dispatch = new CRecep_sample_dispatchFactory().GetByPrimaryKey(new CRecep_sample_dispatchKeys(oRecep_sample.Idrecep_sample));
                if (oRecep_sample_dispatch != null)
                {
                    // --- person
                    if (oRecep_sample_dispatch.Dispatch_person > 0)
                        ckDispatchPerson.Checked = true;
                    else
                        ckDispatchPerson.Checked = false;
                    // --- curier
                    if (oRecep_sample_dispatch.Dispatch_curier > 0)
                        ckDispatchCurier.Checked = true;
                    else
                        ckDispatchCurier.Checked = false;
                    // --- transport
                    if (oRecep_sample_dispatch.Dispatch_transport > 0)
                        ckDispatchTransport.Checked = true;
                    else
                        ckDispatchTransport.Checked = false;
                    // --- fax
                    if (oRecep_sample_dispatch.Dispatch_fax > 0)
                        ckDispatchFax.Checked = true;
                    else
                        ckDispatchFax.Checked = false;
                }
                else
                {
                    ckDispatchPerson.Checked = false;
                    ckDispatchCurier.Checked = true;
                    ckDispatchTransport.Checked = false;
                    ckDispatchFax.Checked = false;
                }

                // --- return date of client
                if (oCompany != null)
                {
                    IDCompany = oCompany.Idcompany;
                    cbCompany.EditValue = oCompany.Idcompany;
                    tbClientRuc.Text = oCompany.Ruc;
                    tbClientPhone.Text = oCompany.Phone_client;
                    tbClientDomicile.Text = oCompany.Domicile;

                    // --- get contacts
                    gcContact.DataSource = new BindingList<CContact>(oReception.GetLstContactsByRecep(oRecep_sample.Idrecep_sample));

                    // --- return recep_sample_detail
                    CRecep_sample_detail oRecep_sample_detail = new CRecep_sample_detail();
                    CRecep_sample_detailFactory faRecep_sample_detail = new CRecep_sample_detailFactory();

                    DTReceptionDetail = oReception.GetReceptionDetail(oRecep_sample.Idrecep_sample);
                    gcReception.DataSource = DTReceptionDetail;

                    // --- return columns
                    List<CTemplate_method> lstTemplate_method = oReception.GetReceptionElem(oRecep_sample.Idrecep_sample);

                    // --- modify the dictionary show columns

                    if (loadData != LoadData.FromRR_ToExtendRR)
                    {
                        foreach (CTemplate_method oTemplate_method in lstTemplate_method)
                            AddColumn(oTemplate_method.Cod_template_method);

                        // --- get columns and value cells
                        GetSampleByElems();
                    }

                    // ==================< Retrieve report groups >==============================================
                    gcReport.DataSource = oReception.GetRecep_sample_report(oRecep_sample.Idrecep_sample);
                    CCells_reportedFactory faCells_reported = new CCells_reportedFactory();
                    for (int i = 0; i < gvReport.RowCount; i++)
                    {
                        long idrecep_sample_report = Convert.ToInt64(gvReport.GetRowCellValue(i, gcRep_idrecep_sample_report));
                        short order = Convert.ToInt16(gvReport.GetRowCellValue(i, gcRep_order_report));

                        Color color = dicColorReport[Convert.ToInt16(gvReport.GetRowCellValue(i, gcRep_report_status))];

                        List<CCells_reported> lstRsder = faCells_reported.GetAll().Where(x=> x.Idrecep_sample_report == idrecep_sample_report).ToList();
                        List<CPositionValue> lstPositionValue = new List<CPositionValue>();

                        foreach (CCells_reported item in lstRsder)
                        {
                            if (item.Idrecep_sample_report == idrecep_sample_report)
                            {
                                CPositionValue oPosition = new CPositionValue();
                                oPosition = GetObjectPosition(Convert.ToInt64(item.Idrecep_sample_detail_elem), Convert.ToInt32(item.Idtemplate_method));

                                oPosition.idtemplate_method = Convert.ToInt32(item.Idtemplate_method);
                                oPosition.idrecep_sample_report = Convert.ToInt64(item.Idrecep_sample_report);
                                oPosition.idrecep_sample_detail = Convert.ToInt64(item.Idrecep_sample_detail);
                                oPosition.idrecep_sample_detail_elem = Convert.ToInt64(item.Idrecep_sample_detail_elem);
                                oPosition.idcell_reported = Convert.ToInt64(item.Idcell_reported);

                                if (Convert.ToInt16(gvReport.GetRowCellValue(i, gcRep_type_report)) == 1)
                                    oPosition.color = Partial_report_color;
                                else
                                    oPosition.color = Final_report_color;

                                lstPositionValue.Add(oPosition);
                            }
                        }

                        DicCellsSavedReport.Add(order, lstPositionValue);
                    }

                    // ==================< Unreport data >======================================================
                    GetUnreportData(oRecep_sample.Idrecep_sample);

                    // ==================< Retrieve attach files >==============================================
                    gcAttachFile.DataSource = new BindingList<CDocAttach>(oReception.GetLstDocAttach(oRecep_sample.Idrecep_sample));
                    CCells_attach_fileFactory faCells_attach_file = new CCells_attach_fileFactory();
                    for (int i = 0; i < gvAttachFile.RowCount; i++)
                    {
                        long idrecep_sample_attach = Convert.ToInt64(gvAttachFile.GetRowCellValue(i, gcAtt_Idrecep_sample_attach));
                        short order = Convert.ToInt16(gvAttachFile.GetRowCellValue(i, gcAtt_Order_file));

                        Color color = dicColorAttach[Convert.ToInt16(gvAttachFile.GetRowCellValue(i, gcAtt_Attach_status))];

                        List<CCells_attach_file> lstRsder = oReception.GetLstCellsAttachFile(idrecep_sample_attach);
                        List<CpositionValueAttach> lstPositionValue = new List<CpositionValueAttach>();

                        foreach (CCells_attach_file item in lstRsder)
                        {
                            if (item.Idrecep_sample_attach == idrecep_sample_attach)
                            {
                                CpositionValueAttach oPosition = new CpositionValueAttach();
                                oPosition = GetObjectPositionAttach(Convert.ToInt64(item.Idrecep_sample_detail_elem), Convert.ToInt32(item.Idtemplate_method));
                                oPosition.idrecep_sample_detail_elem = Convert.ToInt64(item.Idrecep_sample_detail_elem);
                                oPosition.idtemplate_method = Convert.ToInt32(item.Idtemplate_method);
                                oPosition.color = color;

                                lstPositionValue.Add(oPosition);
                            }
                        }

                        DicCellsSavedAttach.Add(order, lstPositionValue);
                    }

                    // ==================< Retrieve program >==============================================
                    gcProgram.DataSource = oReception.GetRecep_sample_program(oRecep_sample.Idrecep_sample);
                    CCells_programFactory faCells_program = new CCells_programFactory();

                    for (int i = 0; i < gvProgram.RowCount; i++)
                    {
                        long idrecep_sample_program = Convert.ToInt64(gvProgram.GetRowCellValue(i, gcProg_Idrecep_sample_program));
                        short order = Convert.ToInt16(gvProgram.GetRowCellValue(i, gcProg_Order_report));

                        Color color = Comun.ColorRojo;

                        List<CCells_program> lstProgram = oReception.GetLstCellsProgram(idrecep_sample_program);
                        List<CPositionValueProgram> lstPositionValueProgram = new List<CPositionValueProgram>();

                        foreach (CCells_program item in lstProgram)
                        {
                            if (item.Idrecep_sample_program == idrecep_sample_program)
                            {
                                CPositionValueProgram oPosition = new CPositionValueProgram();
                                oPosition = GetObjectPositionProgram(Convert.ToInt64(item.Idrecep_sample_detail_elem), Convert.ToInt32(item.Idtemplate_method));

                                oPosition.idrecep_sample_program = Convert.ToInt64(item.Idrecep_sample_program);
                                oPosition.idrecep_sample_detail_elem = Convert.ToInt64(item.Idrecep_sample_detail_elem);
                                oPosition.idrecep_sample_detail = Convert.ToInt64(item.Idrecep_sample_detail);
                                oPosition.idtemplate_method = Convert.ToInt32(item.Idtemplate_method);
                                oPosition.color = color;

                                lstPositionValueProgram.Add(oPosition);
                            }
                        }

                        DicCellsSaveProgram.Add(order, lstPositionValueProgram);
                    }

                }
                SortColumnsByCodTemplate();
            }
            else
            {
                ///No existe un registro de recepción, entonces recuperar todo vacio
                // --- hide tappages
                tpRightReports.PageVisible = false;
                tpRightAttach.PageVisible = false;
                tpRightProgram.PageVisible = false;

                // --- return empty report
                CRecep_sample_reportFactory faRecep_sample_report = new CRecep_sample_reportFactory();
                gcReport.DataSource = oReception.GetRecep_sample_report(0);

                // --- return empty attach files
                gcAttachFile.DataSource = new BindingList<CDocAttach>(oReception.GetLstDocAttach(0));

                // --- recuperar contactos
                if (cbCompany.EditValue != null)
                    gcContact.DataSource = new BindingList<CContact>(oReception.GetLstContactsByCompany(Convert.ToInt16(cbCompany.EditValue)));
            }
        }
Beispiel #4
0
        private CPositionValue findReport(int row, DevExpress.XtraGrid.Columns.GridColumn col)
        {
            if (lstItemsSelReport.Count > 0)
            {
                // se está seleccionando celdas
                foreach (GridCell[] gridcells in lstItemsSelReport)
                {
                    foreach (GridCell gridcell in gridcells)
                    {
                        CPositionValue oPosition = new CPositionValue();
                        oPosition.col = col;
                        oPosition.row = row;
                        oPosition.color = dicColorReport[1];

                        if (gridcell.RowHandle == row &&
                            gridcell.Column == col)
                            return oPosition;
                    }
                }
            }

            if (DicCellsSavedReport.ContainsKey(Convert.ToInt16(gvReport.GetFocusedRowCellValue(gcRep_order_report))))
            {
                // --- pasó la etapa de selección de celdas, mostrar solo el reporte seleccionado
                List<CPositionValue> lstPosition = DicCellsSavedReport[Convert.ToInt16(gvReport.GetFocusedRowCellValue(gcRep_order_report))];

                foreach (CPositionValue oPosition in lstPosition)
                {
                    oPosition.col = col;
                    oPosition.row = row;

                    CTagInfoMethod tagMethod = col.Tag as CTagInfoMethod;
                    long idrecep_sample_detail = Convert.ToInt64(gvReception.GetRowCellValue(row, gcRec_idrecep_sample_detail));

                    if (oPosition.idrecep_sample_detail == idrecep_sample_detail && oPosition.idtemplate_method == tagMethod.IDTemplate_method)
                        return oPosition;
                }
            }
            return null;
        }