void LoadQaqcStatus() { if (TypeSample == Comun.TypeSample.Sample) { // --- get repetitions repRepetition.DataSource = Comun.ListTypeRepetition; repRepetition.DisplayMember = "Name_repetition"; repRepetition.ValueMember = "Cod_repetition"; // --- get methods CTemplate_methodFactory faTemplate_method = new CTemplate_methodFactory(); CTemplate_method oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idtemplate_method)); Methods oMethods = new Methods(); gcMethods.DataSource = oMethods.GetAllLastVersionMethods(Convert.ToInt32(oTemplate_method.Idelement), oTemplate_method.Cod_type_sample); // --- assign to popup controls // observation Idtemplate_method = Convert.ToInt32(gvMethods.GetFocusedRowCellValue(gcMet_Idtemplate_method)); tbObservation.Text = Text_obs; // method if (Idretest > 0) { faTemplate_method = new CTemplate_methodFactory(); oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idretest)); tbCod_method.Text = oTemplate_method.Cod_template_method; tbAbbrevMethod.Text = oTemplate_method.Abbreviation; ckEnableRetest.Checked = true; } else { faTemplate_method = new CTemplate_methodFactory(); oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idtemplate_method)); tbCod_method.Text = oTemplate_method.Cod_template_method; tbAbbrevMethod.Text = oTemplate_method.Abbreviation; ckEnableRetest.Checked = false; ckChangeMethod.Checked = false; } // --- get retest #region codigo anterior /* CREATE OR REPLACE FUNCTION public.sp_retest_getBySample(p_idrecep_sample_detail_elem bigint, p_idbatch bigint) returns TABLE ("Idbatch" BIGINT, "Num_tray" VARCHAR, "Idrecep_sample_detail_elem" BIGINT, "Idrecep_sample_detail" BIGINT ,"Cod_module" VARCHAR, "Cod_process" VARCHAR, "Status_process" CHAR, "Result_analysis" DECIMAL , "Str_result_analysis" VARCHAR, "Status_result" int, "Cod_sample" VARCHAR , "Flag_current_batch" boolean )AS $$ BEGIN -- CREATE TEMP TABLE tmp_batch ON COMMIT DROP AS SELECT origin_batch as idbatch, idrecep_sample_detail_elem, idrecep_sample_detail FROM retest WHERE (origin_batch = p_idbatch OR destiny_batch = p_idbatch) UNION ALL SELECT destiny_batch as idbatch, idrecep_sample_detail_elem, idrecep_sample_detail FROM retest WHERE (destiny_batch = p_idbatch OR origin_batch = p_idbatch); RETURN QUERY SELECT DISTINCT t1.idbatch, CAST(LPAD(CAST(t2.num_tray AS VARCHAR), 5, '0') AS VARCHAR), t1.idrecep_sample_detail_elem, t4.idrecep_sample_detail , t2.cod_module, t2.cod_process, t2.status_process, t3.result_analysis , t3.str_result_analysis, COALESCE(CAST(t3.Qaqc_status_result AS INT), 0) as ER, t3.cod_sample , CAST(CASE WHEN t1.idbatch = p_idbatch THEN 1 ELSE 0 END AS BOOLEAN) AS flag_current_batch FROM tmp_batch t1 INNER JOIN batch t2 ON t1.idbatch = t2.idbatch LEFT OUTER JOIN batch_detail_aa_twofold t3 ON t2.idbatch = t3.idbatch AND t1.idrecep_sample_detail_elem = t3.idrecep_sample_detail_elem LEFT OUTER JOIN recep_sample_detail t4 ON t1.idrecep_sample_detail = t4.idrecep_sample_detail WHERE t1.idrecep_sample_detail_elem = p_idrecep_sample_detail_elem; END; $$ LANGUAGE plpgsql; */ #endregion var tmp_batch = (from m in new CRetestFactory().GetAll().Where(x => x.Origin_batch == Idbatch || x.Destiny_batch == Idbatch) select new { idbatch = m.Origin_batch, m.Idrecep_sample_detail_elem, m.Idrecep_sample_detail }) .Union(from m in new CRetestFactory().GetAll().Where(x => x.Destiny_batch == Idbatch || x.Origin_batch == Idbatch) select new { idbatch = m.Destiny_batch, m.Idrecep_sample_detail_elem, m.Idrecep_sample_detail }); var query2 = (from m in tmp_batch.Where(x => x.Idrecep_sample_detail_elem == Idrecep_sample_detail_elem) from n in new CBatchFactory().GetAll().Where(x => x.Idbatch == m.idbatch) join p in new CBatch_detail_aa_twofoldFactory().GetAll() on new { field1 = m.idbatch, field2 = m.Idrecep_sample_detail_elem } equals new { field1 = p.Idbatch, field2 = p.Idrecep_sample_detail_elem } into np from q in np.DefaultIfEmpty() join r in new CRecep_sample_detailFactory().GetAll() on q.Idrecep_sample_detail equals r.Idrecep_sample_detail into qr from s in qr select new { m.idbatch, Num_tray = n.Num_tray.ToString().PadLeft(5, '0'), m.Idrecep_sample_detail_elem, m.Idrecep_sample_detail, n.Cod_module, n.Cod_process, n.Status_process, q.Result_analysis, q.Str_result_analysis, Status_result = q == null ? 0 : q.Qaqc_status_result, q.Cod_sample, Flag_current_batch = m.idbatch == Idbatch ? true : false }).Distinct(); gcListRetest.DataSource = query2; Show_controls(Windows_current); } else { // --- reensayo de muestras de control de encontrar algún error gcObservation.Visible = false; ckEnableRetest.Visible = false; xtraTabControl1.TabPages[0].Text = "Reensayo de Bandeja"; xtraTabControl1.TabPages[1].PageVisible = false; // --- get repetitions repRepetition.DataSource = Comun.ListTypeRepetition; repRepetition.DisplayMember = "Name_repetition"; repRepetition.ValueMember = "Cod_repetition"; // --- get methods CTemplate_methodFactory faTemplate_method = new CTemplate_methodFactory(); CTemplate_method oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idtemplate_method)); Methods oMethods = new Methods(); gcMethods.DataSource = oMethods.GetAllLastVersionMethods(Convert.ToInt32(oTemplate_method.Idelement), oTemplate_method.Cod_type_sample); // --- assign to popup controls // observation Idtemplate_method = Convert.ToInt32(gvMethods.GetFocusedRowCellValue(gcMet_Idtemplate_method)); tbObservation.Text = Text_obs; // method faTemplate_method = new CTemplate_methodFactory(); oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idtemplate_method)); tbCod_method.Text = oTemplate_method.Cod_template_method; tbAbbrevMethod.Text = oTemplate_method.Abbreviation; ckEnableRetest.Checked = true; ckChangeMethod.Checked = false; ckEnableRetest.Visible = false; } }