public CpositionValueAttach GetObjectPositionAttach(long idrecep_sample_detail, int idtemplate_method) { CpositionValueAttach positionValueAttach = new CpositionValueAttach(); 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) { positionValueAttach.idtemplate_method = idtemplate_method; positionValueAttach.idrecep_sample_detail = idrecep_sample_detail; positionValueAttach.idrecep_sample_detail_elem = Convert.ToInt64(DTReceptionDetailElem.Rows[i]["idrecep_sample_detail_elem"]); } } return positionValueAttach; }
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))); } }