public BindingList <CCustom_method_solution> GetMethodsByMrcPattern(int idelement, short idmr_detail, int?idreactive_medium, int?idreactive_modif, int?idgroup_solution) { List <CTemplate_method_aa> lstTemplate_method_aa = new CTemplate_method_aaFactory() .GetAll() .Where(c => c.Mrorpattern == idmr_detail && c.Medium == idreactive_medium && c.Modif == idreactive_modif).ToList(); List <CTemplate_method> lstTemplate_method = new CTemplate_methodFactory() .GetAll() .Where(c => c.Idelement == idelement).ToList(); var query_group_methods = new CGroup_solution_methodsFactory().GetAll().Where(c => c.Idgroup_solution == idgroup_solution).ToList(); BindingList <CCustom_method_solution> query = new BindingList <CCustom_method_solution>( (from m in lstTemplate_method join n in lstTemplate_method_aa on m.Idtemplate_method equals n.Idtemplate_method join p in query_group_methods on n.Idtemplate_method equals p.Idtemplate_method into ps from q in ps.DefaultIfEmpty() select new CCustom_method_solution { Sel = q == null ? false : Convert.ToBoolean(q.Status), Idtemplate_method = n.Idtemplate_method, Cod_template_method = m.Cod_template_method, Title = m.Title } ).ToList()); return(query); }
public DataTable GetReceptionDetailElem(long idrecep_sample) { List <CRecep_sample_detail_elem> lstRecep_sample_detail_elem = new CRecep_sample_detail_elemFactory().GetAll().Where(c => c.Idrecep_sample == idrecep_sample).ToList(); List <CElement> lstElement = new CElementFactory().GetAll(); List <CTemplate_method> lstTemplate_method = new CTemplate_methodFactory().GetAll(); List <CReception_detail_elem> lst = (from t1 in lstRecep_sample_detail_elem join t2 in lstElement on t1.Idelement equals t2.Idelement join t3 in lstTemplate_method on t1.Idtemplate_method equals t3.Idtemplate_method select new CReception_detail_elem { Idrecep_sample = Convert.ToInt64(t1.Idrecep_sample), Idrecep_sample_detail = Convert.ToInt32(t1.Idrecep_sample_detail), Idrecep_sample_detail_elem = t1.Idrecep_sample_detail_elem, Idtemplate_method = Convert.ToInt32(t1.Idtemplate_method), Idelement = Convert.ToInt16(t1.Idelement), Cod_element = t2.Cod_element, Abbreviation = t3.Abbreviation, Result_analysis = Convert.ToDecimal(t1.Result_analysis), Str_result_analysis = t1.Str_result_analysis, Cod_template_method = t3.Cod_template_method }).ToList <CReception_detail_elem>(); return(ToDataTable <CReception_detail_elem>(lst)); }
public BindingList <CCustom_method_solution> GetMethodsBySolution(int idelement, int idsolution, int?idreactive_medium, int?idreactive_modif, int?idgroup_solution) { List <CTemplate_method_aa> lstTemplate_method_aa = new CTemplate_method_aaFactory() .GetAll() .Where(c => /*c.Sol_intermedia == idsolution &&*/ c.Medium == idreactive_medium && c.Modif == idreactive_modif).ToList(); List <CTemplate_method> lstTemplate_method = new CTemplate_methodFactory() .GetAll() .Where(c => c.Idelement == idelement).ToList(); var query_group_methods = new CGroup_solution_methodsFactory().GetAll().Where(c => c.Idgroup_solution == idgroup_solution).ToList(); BindingList <CCustom_method_solution> query = new BindingList <CCustom_method_solution>( (from m in lstTemplate_method join n in lstTemplate_method_aa on m.Idtemplate_method equals n.Idtemplate_method join p in query_group_methods on n.Idtemplate_method equals p.Idtemplate_method into ps from q in ps.DefaultIfEmpty() select new CCustom_method_solution { Sel = q == null ? false : true, Idtemplate_method = n.Idtemplate_method, Cod_template_method = m.Cod_template_method, Title = m.Title } ).ToList()); return(query); }
public List <CTemplate_method> GetMethodsCalib(int idelement, short idmr_detail) { var lstTemplate_method = new CTemplate_methodFactory() .GetAll() .Where(c => c.Idelement == idelement).ToList(); var lsTemplate_method_aa = new CTemplate_method_aaFactory() .GetAll() .Where(c => c.Mrorpattern == idmr_detail).ToList(); var lst = (from t1 in lstTemplate_method join t2 in lsTemplate_method_aa on t1.Idtemplate_method equals t2.Idtemplate_method select t1 ).ToList <CTemplate_method>(); foreach (var item in lst) { item.Cod_template_method = item.Cod_template_method + " - " + item.Title; } return(lst); }
public List <CAbsorcionAtomica> GetMethodsAbsorcionAtomica(int idtemplate_method) { List <CTemplate_method> lstTemplate_method = new CTemplate_methodFactory().GetAll().Where(c => c.Idtemplate_method == idtemplate_method).ToList(); List <CTemplate_method_aa> lstTemplate_method_aa = new CTemplate_method_aaFactory().GetAll().Where(c => c.Idtemplate_method == idtemplate_method).ToList(); return((from t1 in lstTemplate_method join t2 in lstTemplate_method_aa on t1.Idtemplate_method equals t2.Idtemplate_method where t1.Idtemplate_method == t2.Idtemplate_method select new CAbsorcionAtomica { Idtemplate_method = t1.Idtemplate_method, Num_version = t1.Num_version, Cod_template_method = t1.Cod_template_method, Name_repetition = CaseRepetition(t1.Cod_repetition), Title = t1.Title, Abbreviation = t1.Abbreviation, Name_type_analysis = CaseTypeAnalysis(t1.Type_analisys), Name_type_sample = CaseTypeSample(t1.Cod_type_sample), Name_digestion = CaseDigestion(t1.Cod_digestion_method), Name_unit_result = CaseUnitMeasure(t2.Idunit_result), Weight = t2.Weight, Volumen = t2.Volumen, Reading_min = t2.Reading_min, Reading_max = t2.Reading_max, Dilution2 = t2.Dilution2, Dilution3 = t2.Dilution3, Reason_rep = t2.Reason_rep, Law_limit_bottom = t2.Law_limit_bottom, Law_limit_top = t2.Law_limit_top, Name_unit_calib = CaseUnitMeasure(t2.Idunit_calib) } ).ToList <CAbsorcionAtomica>()); }
public List <CTemplate_method> GetAllLastVersionMethods() { List <CTemplate_method> lstTemplate = new CTemplate_methodFactory().GetAll(); List <CTemplate_method> lstTemplateVersion = (from t1 in lstTemplate group t1 by new { t1.Cod_template_method, t1.Abbreviation, t1.Cod_repetition, t1.Cod_digestion_method, t1.Title } into grp select new CTemplate_method { Cod_template_method = grp.Key.Cod_template_method, Abbreviation = grp.Key.Abbreviation, Cod_repetition = grp.Key.Cod_repetition, Cod_digestion_method = grp.Key.Cod_digestion_method, Idtemplate_method = grp.Max(c => c.Idtemplate_method), Title = grp.Key.Cod_template_method + " - " + grp.Key.Title }).ToList <CTemplate_method>(); return((from t1 in lstTemplateVersion join t2 in lstTemplate on t1.Idtemplate_method equals t2.Idtemplate_method orderby t2.Cod_template_method select new CTemplate_method { Abbreviation = t2.Abbreviation, Cod_repetition = t2.Cod_repetition, Cod_template_method = t2.Cod_template_method, Cod_type_sample = t2.Cod_type_sample, Cost_method = t2.Cost_method, Cod_digestion_method = t2.Cod_digestion_method, Idelement = t2.Idelement, Idtemplate_method = t2.Idtemplate_method, Type_analisys = t2.Type_analisys, Title = t2.Cod_template_method + " - " + t2.Title }).ToList <CTemplate_method>()); }
protected override void Recuperar_Registro() { try { // --- recuperate head if (IDTemplate_Method > 0) { // --- recuperate head CTemplate_methodFactory faTemplate_Method = new CTemplate_methodFactory(); CTemplate_method oTemplate_Method = faTemplate_Method.GetByPrimaryKey(new CTemplate_methodKeys(IDTemplate_Method)); gluCod_method.EditValue = oTemplate_Method.Cod_template_method; Num_version = Convert.ToInt16(oTemplate_Method.Num_version); tbTitle.Text = oTemplate_Method.Title; laTitulo.Text = string.Format("Metodo ({0}-{1})", oTemplate_Method.Num_version, oTemplate_Method.Useredit); cbDigestion.EditValue = oTemplate_Method.Cod_digestion_method; tbCost_Method.Value = Convert.ToDecimal(oTemplate_Method.Cost_method); tbAbreviation.Text = oTemplate_Method.Abbreviation; ckRecognized.Checked = Convert.ToBoolean(oTemplate_Method.Recognized); cbTypeSample.EditValue = oTemplate_Method.Cod_type_sample; cbElement.EditValue = Convert.ToInt16(oTemplate_Method.Idelement); cbTypeAnalysis.EditValue = null; cbTypeAnalysis.EditValue = oTemplate_Method.Type_analisys; //recupera el tipo de analisis cbRepetition.EditValue = oTemplate_Method.Cod_repetition; } } catch (Exception ex) { ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message); } }
public void RetestBatch() { try { CBatchFactory faBatch = new CBatchFactory(); CBatch oBatch = faBatch.GetByPrimaryKey(new CBatchKeys(Idbatch)); // --- check parity for (int i = 0; i < ListSamples.Count; i++) { CBatch_detail_aa_twofold row = ListSamples[i]; CBatch_detail_aa_twofoldFactory faBatch_detail_aa_twofold = new CBatch_detail_aa_twofoldFactory(); if (Convert.ToInt32(row.Flag_mri) == 0) { // --- approved samples with additional retest mark row.Qaqc_has_retest = 1; faBatch_detail_aa_twofold.Update(row); // --- save retest string cod_type_sample = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(Convert.ToInt32(row.Idtemplate_method))).Cod_type_sample; CCorrelative oCorrelative = new CCorrelativeFactory().GetByPrimaryKey(new CCorrelativeKeys(cod_type_sample)); CBatchManager oBatchManager = new CBatchManager(); oBatchManager.CallSaveFromRetestFullBatch( Convert.ToInt32(row.Idtemplate_method), Convert.ToInt64(row.Idrecep_sample), Convert.ToInt64(row.Idrecep_sample_detail), Convert.ToInt64(row.Idrecep_sample_detail_elem), Convert.ToInt64(row.Cod_interno), row.Cod_sample, Comun.GetUser(), oCorrelative, row.Qaqc_par); // --- register as finished trace process CProcess_Sample_Manage.Finalize_process(Convert.ToInt64(row.Idrecep_sample_detail_elem), LimsProcess.PROCESS_IN_READING, LimsProcess.PROCESS_APPROVE_SAMPLES); } } // --- modify the batch status, put in other process CProcess oProcess = new CProcessFactory().GetByPrimaryKey(new CProcessKeys(LimsProcess.PROCESS_APPROVE_SAMPLES)); oBatch.Status_process = Convert.ToChar(LimsProcess.Status_Process.Waiting); oBatch.Cod_module = oProcess.Cod_module; oBatch.Cod_area = oProcess.Cod_area; oBatch.Cod_process = LimsProcess.PROCESS_APPROVE_SAMPLES; oBatch.User_approve_tray = Comun.GetUser(); oBatch.Date_approve_tray = Comun.GetDate(); faBatch.Update(oBatch); // --- register as finished trace batch Cprocess_Batch_Manage.Finalize_process(Idbatch, LimsProcess.PROCESS_IN_READING, LimsProcess.PROCESS_APPROVE_SAMPLES); } catch (Exception ex) { Comun.Save_log(ex.InnerException.ToString()); throw new Exception("pivot data::approve::Error occured.", ex); } }
public short GetNumNewVersion(int idtemplate_method) { // --- get last version short num_version = new CTemplate_methodFactory().GetAll().Where(c => c.Idtemplate_method == idtemplate_method).Max(d => Convert.ToInt16(d.Num_version)); num_version++; return(num_version); }
public void SaveControlSample(int idtemplate_method_aa, long idbatch) { CTemplate_method template_method = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(idtemplate_method_aa)); CCorrelative correlative = new CCorrelativeFactory().GetByPrimaryKey(new CCorrelativeKeys(template_method.Cod_type_sample)); CTemplate_method_aa templaate_method_aa = new CTemplate_method_aaFactory().GetByPrimaryKey(new CTemplate_method_aaKeys(idtemplate_method_aa)); control_sample.Idtemplate_method = templaate_method_aa.Idtemplate_method; //control_sample.Idrecep_sample = idrecep_sample; //control_sample.Idrecep_sample_detail = idrecep_sample_detail; //control_sample.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; control_sample.Weight1 = templaate_method_aa.Weight; control_sample.Weight2 = templaate_method_aa.Weight; control_sample.Volumen1 = templaate_method_aa.Volumen; control_sample.Volumen2 = templaate_method_aa.Volumen; control_sample.Dilu2 = templaate_method_aa.Dilution2; control_sample.Dilu3 = templaate_method_aa.Dilution3; control_sample.Flag_dilu2 = false; control_sample.Flag_dilu3 = false; control_sample.Flag_mri = 1; control_sample.Fum = methods.GetFactorConvertionUM(templaate_method_aa.Idtemplate_method); control_sample.Qaqc_blk = 3; control_sample.Qaqc_par = 3; control_sample.Qaqc_mr = 3; control_sample.Qaqc_error = 0; control_sample.Qaqc_approve = false; control_sample.Qaqc_review = false; control_sample.Qaqc_has_retest = 0; control_sample.Qaqc_tmp_retest = 0; control_sample.Qaqc_tmp_retest_idmethod = 0; control_sample.Qaqc_approve_text = ""; control_sample.Qaqc_review_text = ""; // --- insert mri CBatch oBatch = new CBatchFactory().GetByPrimaryKey(new CBatchKeys(idbatch)); int num_free_places = GetNumFreePlacesInBatch(idbatch, templaate_method_aa.Idtemplate_method); if (num_free_places >= 1) { if (!Convert.ToBoolean(oBatch.Has_sample_control)) // batch no tiene mri { long index_mri = GetIndexMriPosition(idbatch); if (index_mri > 0) { // --- insert mri control_sample.Cod_interno = index_mri; control_sample.Idbatch = idbatch; control_sample.Cod_sample = Comun.FormatCorrelativeCode(correlative.Prefix + correlative.Cod_serie, index_mri, Convert.ToInt32(correlative.Num_digits)); if (faBatch_detail_aa_twofold.Insert(control_sample)) { oBatch.Has_sample_control = true; new CBatchFactory().Update(oBatch); } } } } }
Comun.MethodSaveProperty GetResultTestHeader() { // --- registro anterior if (IDTemplate_Method <= 0) { return(Comun.MethodSaveProperty.NewMethod); } else { CTemplate_methodFactory faTemplate_method = new CTemplate_methodFactory(); CTemplate_method oTemplate_method = new CTemplate_method(); oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(IDTemplate_Method)); CTemplate_method_aa oTemplate_method_aa = new CTemplate_method_aa(); CTemplate_method_aaFactory faTemplate_method_aa = new CTemplate_method_aaFactory(); oTemplate_method_aa = faTemplate_method_aa.GetByPrimaryKey(new CTemplate_method_aaKeys(IDTemplate_Method)); // --- change inside head, require new method if (oTemplate_method.Idelement != Convert.ToInt16(cbElement.EditValue)) { return(Comun.MethodSaveProperty.InspectionNewMethod); } if (oTemplate_method.Cod_type_sample != cbTypeSample.EditValue.ToString()) { return(Comun.MethodSaveProperty.InspectionNewMethod); } if (oTemplate_method.Type_analisys != Convert.ToChar(cbTypeAnalysis.EditValue)) { return(Comun.MethodSaveProperty.InspectionNewMethod); } if (oTemplate_method.Cod_template_method != gluCod_method.Text) { return(Comun.MethodSaveProperty.InspectionNewMethod); } //if (oTemplate_method.Abbreviation != tbAbreviation.Text) // return Comun.MethodSaveProperty.InspectionNewMethod; //if (oTemplate_method.Title != tbTitle.Text) // return Comun.MethodSaveProperty.InspectionNewMethod; //if (oTemplate_method.Recognized != ckRecognized.Checked) // return Comun.MethodSaveProperty.InspectionNewMethod; if (oTemplate_method.Cod_digestion_method != cbDigestion.EditValue.ToString()) { return(Comun.MethodSaveProperty.InspectionNewMethod); } //if (Convert.ToDecimal(oTemplate_method.Cost_method) != tbCost_Method.Value) // return Comun.MethodSaveProperty.InspectionNewMethod; if (Convert.ToInt16(oTemplate_method.Cod_repetition) != Convert.ToInt16(cbRepetition.EditValue)) { return(Comun.MethodSaveProperty.InspectionNewMethod); } return(Comun.MethodSaveProperty.Nothing); } }
void FilterByCodMethod() { CTemplate_methodFactory faTemplate_Method = new CTemplate_methodFactory(); IDTemplate_Method = Convert.ToInt32(gluCod_method.EditValue); CTemplate_method oTemplate_Method = faTemplate_Method.GetByPrimaryKey(new CTemplate_methodKeys(IDTemplate_Method)); if (oTemplate_Method != null) { cbElement.EditValue = Convert.ToInt16(oTemplate_Method.Idelement); cbTypeSample.EditValue = oTemplate_Method.Cod_type_sample; cbTypeAnalysis.EditValue = oTemplate_Method.Type_analisys; } }
public PriceMethod(CPrice_version_detail version, BindingList <PriceMethodHistory> history) { Idprice_version = version.Idprice_version; Idprice_version_detail = version.Idprice_version_detail; Num_item = version.Num_item; Idtemplate_method = version.Idtemplate_method; CTemplate_method oTemplate_method = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(Convert.ToInt32(version.Idtemplate_method))); CTemplate_method_aa oTemplate_method_aa = new CTemplate_method_aaFactory().GetByPrimaryKey(new CTemplate_method_aaKeys(Convert.ToInt32(version.Idtemplate_method))); Den_method = oTemplate_method.Cod_template_method + " - " + oTemplate_method.Title; Amount_item = version.Amount_item; Rank = oTemplate_method_aa.Reading_min.ToString() + " - " + oTemplate_method_aa.Reading_max.ToString(); Unit_price = version.Unit_price; Sale_price = version.Sale_price; History = history; }
Comun.MethodSaveProperty GetResultTestHeader() { // --- registro anterior if (IDTemplate_Method <= 0) { return Comun.MethodSaveProperty.NewMethod; } else { CTemplate_methodFactory faTemplate_method = new CTemplate_methodFactory(); CTemplate_method oTemplate_method = new CTemplate_method(); oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(IDTemplate_Method)); CTemplate_method_aa oTemplate_method_aa = new CTemplate_method_aa(); CTemplate_method_aaFactory faTemplate_method_aa = new CTemplate_method_aaFactory(); oTemplate_method_aa = faTemplate_method_aa.GetByPrimaryKey(new CTemplate_method_aaKeys(IDTemplate_Method)); // --- change inside head, require new method if (oTemplate_method.Idelement != Convert.ToInt16(cbElement.EditValue)) return Comun.MethodSaveProperty.InspectionNewMethod; if (oTemplate_method.Cod_type_sample != cbTypeSample.EditValue.ToString()) return Comun.MethodSaveProperty.InspectionNewMethod; if (oTemplate_method.Type_analisys != Convert.ToChar(cbTypeAnalysis.EditValue)) return Comun.MethodSaveProperty.InspectionNewMethod; if (oTemplate_method.Cod_template_method != gluCod_method.Text) return Comun.MethodSaveProperty.InspectionNewMethod; //if (oTemplate_method.Abbreviation != tbAbreviation.Text) // return Comun.MethodSaveProperty.InspectionNewMethod; //if (oTemplate_method.Title != tbTitle.Text) // return Comun.MethodSaveProperty.InspectionNewMethod; //if (oTemplate_method.Recognized != ckRecognized.Checked) // return Comun.MethodSaveProperty.InspectionNewMethod; if (oTemplate_method.Cod_digestion_method != cbDigestion.EditValue.ToString()) return Comun.MethodSaveProperty.InspectionNewMethod; //if (Convert.ToDecimal(oTemplate_method.Cost_method) != tbCost_Method.Value) // return Comun.MethodSaveProperty.InspectionNewMethod; if (Convert.ToInt16(oTemplate_method.Cod_repetition) != Convert.ToInt16(cbRepetition.EditValue)) return Comun.MethodSaveProperty.InspectionNewMethod; return Comun.MethodSaveProperty.Nothing; } }
private void btAdd_Click(object sender, EventArgs e) { if (cbCompany.EditValue != null && cbMethodAdd.EditValue != null) { BindingList <PriceMethod> lst = gcPrice.DataSource as BindingList <PriceMethod>; List <PriceMethod> myLstPriceMethod = lst.ToList(); // agregar un método a la lista int idtemplate_method = Convert.ToInt32(cbMethodAdd.EditValue); CTemplate_method oTemplate_method = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(idtemplate_method)); CPrice_version price_version = new CPrice_version(); price_version.Idprice_version = 0; price_version.Idcompany = Convert.ToInt16(cbCompany.EditValue); price_version.Date_creation = Comun.GetDate(); CPrice_version_detail price_version_detail = new CPrice_version_detail(); price_version_detail.Num_item = myLstPriceMethod.Count + 1; price_version_detail.Amount_item = 1; price_version_detail.Idtemplate_method = idtemplate_method; price_version_detail.Unit_price = oTemplate_method.Cost_method; price_version_detail.Sale_price = oTemplate_method.Cost_method * price_version_detail.Amount_item; myLstPriceMethod.Add( new PriceMethod(price_version_detail, new ModPrice().GetPriceMethodHistory(price_version, price_version_detail.Idtemplate_method))); gcPrice.DataSource = new BindingList <PriceMethod>(myLstPriceMethod); gvPrice.LayoutChanged(); cbMethodAdd.EditValue = null; SumTotals(); ShowPreviewReport(); } }
public List <CCustom_template_method> GetAll(int?idelement, string cod_type_sample, char?type_analysis) { // --- get last version List <CTemplate_method> lstTemplate_method = new CTemplate_methodFactory().GetAll(); // --- get last version var maxVersionTemplate = (from t1 in lstTemplate_method where (t1.Idelement == idelement || idelement == null) && (t1.Cod_type_sample == cod_type_sample || cod_type_sample == null) && (t1.Type_analisys == type_analysis || type_analysis == null) group t1 by new { t1.Idelement, t1.Cod_type_sample, t1.Type_analisys } into grp select new { grp.Key.Idelement, grp.Key.Cod_type_sample, grp.Key.Type_analisys, MaxIdtemplate_method = grp.Max(c => c.Idtemplate_method) }).ToList(); // --- get final query List <CCustom_template_method> lstCustom = (from t1 in lstTemplate_method join t2 in maxVersionTemplate on t1.Idtemplate_method equals t2.MaxIdtemplate_method select new CCustom_template_method { Idtemplate_method = t1.Idtemplate_method, Cod_template_method = t1.Cod_template_method, Repetition = CaseRepetition(t1.Cod_repetition), Title = t1.Title, Abbreviation = t1.Abbreviation }).ToList <CCustom_template_method>(); return(lstCustom); }
public List <CReception_template_method> GetMethodsDenominations(string cod_type_sample) { List <CTemplate_method> lstTemplate = new CTemplate_methodFactory().GetAll(); // --- get last version all methods by cod_type_sample var maxVersionTemplate = (from t1 in lstTemplate group t1 by new { t1.Cod_template_method, t1.Cod_type_sample } into grp select new { grp.Key.Cod_template_method, grp.Key.Cod_type_sample, MaxIdtemplate_method = grp.Max(c => c.Idtemplate_method) }).ToList().Where(q => q.Cod_type_sample == cod_type_sample).ToList(); List <CMeasurement_unit> lstMeasurement_unit = new CMeasurement_unitFactory().GetAll(); List <CElement> lstElement = new CElementFactory().GetAll(); // query absorción atómica var query_aa = (from p in new CTemplate_method_aaFactory().GetAll() from q in lstMeasurement_unit.Where(x => x.Idunit == p.Idunit_result) select new { Idtemplate_method = p.Idtemplate_method, Idunit_result = Convert.ToInt16(p.Idunit_result), Name_unit = q.Name_unit, Analisys_time = Convert.ToDecimal(p.Num_days) / Convert.ToDecimal(p.Num_samples) }).ToList(); // query vía clásica // query icp // query analisis de humedad var query_ah = (from p in new CTemplate_method_ahFactory().GetAll() from q in lstMeasurement_unit.Where(x => x.Idunit == p.Idunit_result) select new { Idtemplate_method = p.Idtemplate_method, Idunit_result = Convert.ToInt16(p.Idunit_result), Name_unit = q.Name_unit, Analisys_time = Convert.ToDecimal(0) }).ToList(); var queryTypeAnalysis = query_aa.Union(query_ah); List <CReception_template_method> lstCustom = (from t1 in lstTemplate from k in queryTypeAnalysis.Where(x => x.Idtemplate_method == t1.Idtemplate_method) join t3 in maxVersionTemplate on t1.Idtemplate_method equals t3.MaxIdtemplate_method join t4 in lstElement on t1.Idelement equals t4.Idelement select new CReception_template_method { Idelement = t1.Idelement, Idtemplate_method = t1.Idtemplate_method, Cod_template_method = t1.Cod_template_method, Abbreviation = t1.Abbreviation, Title = t1.Title, Type_analisys = t1.Type_analisys, Name_type_analisys = CaseNomTypeAnalysis(t1.Type_analisys), Cod_type_sample = t1.Cod_type_sample, Cost_method = t1.Cost_method, Idunit_result = k.Idunit_result, Name_unit = k.Name_unit, Analisys_time = k.Analisys_time, Cod_element = t4.Cod_element }).OrderBy(c => c.Cod_template_method).ToList <CReception_template_method>(); return(lstCustom); }
void Show_batch() { // --- show trace groups gbApprove.Visible = false; gbReview.Visible = false; gv2col_Qaqc_approve.ImageIndex = 0; gv2col_Qaqc_review.ImageIndex = 0; // --- show template method ShowDilution(); // --- show description method CBatchFactory faBatch = new CBatchFactory(); CBatch oBatch = faBatch.GetByPrimaryKey(new CBatchKeys(Idbatch)); laTitleModule.Text = String.Format("Bandeja {0} en Espera", Comun.FormatCorrelativeCode("B-", Convert.ToInt64(oBatch.Num_tray), 5)); if (oBatch.Status_process == 'W') { ucSignCloseTray.Title = "Cerrar bandeja"; ucSignCloseTray.Enabled = true; bgvBatchCalc2.OptionsBehavior.Editable = false; } if (oBatch.Status_process == 'P') { ucSignCloseTray.Title = "Cerrado("+oBatch.User_close_tray+")"; ucSignCloseTray.Enabled = false; bgvBatchCalc2.OptionsBehavior.Editable = true; } CTemplate_methodFactory faTemplate_method = new CTemplate_methodFactory(); oTemplate_method_current = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idtemplate_method)); tbCodMethod.Text = oTemplate_method_current.Cod_template_method; tbTitle.Text = oTemplate_method_current.Title; tbAbbreviation.Text = oTemplate_method_current.Abbreviation; #region <optimizar> CTemplate_method_aaFactory faTemplate_method_aa = new CTemplate_method_aaFactory(); oTemplate_method_aa_current = faTemplate_method_aa.GetByPrimaryKey(new CTemplate_method_aaKeys(Idtemplate_method)); deDate_allowed_error.DateTime = Convert.ToDateTime(oTemplate_method_aa_current.Date_allowed_error); CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = faMr_detail.GetByPrimaryKey(new CMr_detailKeys(Convert.ToInt16(oTemplate_method_aa_current.Idmr_detail))); tbLawMri.Text = oMr_detail.Nominal_value.ToString(); CMrFactory faMr = new CMrFactory(); CMr oMr = faMr.GetByPrimaryKey(new CMrKeys( Convert.ToInt16(oMr_detail.Idmr) )); tbMri.Text = oMr.Cod_mr; CMeasurement_unitFactory faMeasure = new CMeasurement_unitFactory(); CMeasurement_unit oMeasurement_unit = faMeasure.GetByPrimaryKey(new CMeasurement_unitKeys(Convert.ToInt16(oMr_detail.Idunit1))); tbUnitMeasure.Text = oMeasurement_unit.Name_unit; #endregion // --- clear columns gcBachCalc.DataSource = null; // --- format the datatable with the number of repetitions oDataBatch = new CDataBatch(Idbatch, Idtemplate_method, Comun.StatusWork.Waiting, Comun.CriteriaSort.BySample); gcBachCalc.DataSource = oDataBatch.ListSamples; // --- show sd tbAbs.Value = oDataBatch.Absorbance; tbStd.Value = oDataBatch.StdVerification; tbAbs.BackColor = oDataBatch.ColorAbsorbance; tbStd.BackColor = oDataBatch.ColorStd; tbSdBlk.Text = oDataBatch.LrbMeasured.ToString(); tbSdBlk.BackColor = oDataBatch.ColorLrbMeasured; tbSdMr.Text = oDataBatch.MriMeasured.ToString(); tbSdMr.BackColor = oDataBatch.ColorMriMeasured; // --- show empty sample ShowParityEmptySample(false); }
void Show_batch_finished() { gbApprove.Visible = true; gbReview.Visible = true; gv2col_Qaqc_approve.ImageIndex = 0; gv2col_Qaqc_review.ImageIndex = 0; // --- show template method ShowDilution(); // --- show description method CTemplate_methodFactory faTemplate_method = new CTemplate_methodFactory(); CTemplate_method oTemplate_method = faTemplate_method.GetByPrimaryKey(new CTemplate_methodKeys(Idtemplate_method)); tbCodMethod.Text = oTemplate_method.Cod_template_method; tbTitle.Text = oTemplate_method.Title; tbAbbreviation.Text = oTemplate_method.Abbreviation; // --- get batch trace_batch CTrace_batchFactory faTrace_batch = new CTrace_batchFactory(); Dictionary<string, string> dtTrace_batch = new BusinessLayer.Modules.ModProcessBatch().GetCurrentAndBelow(Idbatch, LimsProcess.PROCESS_IN_READING); CBatchFactory faBatch = new CBatchFactory(); CBatch oBatch = faBatch.GetByPrimaryKey(new CBatchKeys(Idbatch)); laTitleModule.Text = String.Format("Bandeja {0} Aprobada\n ({1})" , "B-" + oBatch.Num_tray.ToString().PadLeft(5, '0') , dtTrace_batch["User_approved"].ToString()); laUser_approved.Text = dtTrace_batch["User_approved"].ToString(); laDate_approved.Text = dtTrace_batch["Date_approved"].ToString(); laUser_revised.Text = dtTrace_batch["User_revised"].ToString(); laDate_revised.Text = dtTrace_batch["Date_revised"].ToString(); #region <optimizar> CTemplate_method_aaFactory faTemplate_method_aa = new CTemplate_method_aaFactory(); CTemplate_method_aa oTemplate_method_aa = faTemplate_method_aa.GetByPrimaryKey(new CTemplate_method_aaKeys(Idtemplate_method)); deDate_allowed_error.DateTime = Convert.ToDateTime(oTemplate_method_aa.Date_allowed_error); CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = faMr_detail.GetByPrimaryKey(new CMr_detailKeys(Convert.ToInt16(oTemplate_method_aa.Idmr_detail))); tbLawMri.Text = oMr_detail.Nominal_value.ToString(); CMrFactory faMr = new CMrFactory(); CMr oMr = faMr.GetByPrimaryKey(new CMrKeys( Convert.ToInt16(oMr_detail.Idmr) )); tbMri.Text = oMr.Cod_mr; CMeasurement_unitFactory faMeasure = new CMeasurement_unitFactory(); CMeasurement_unit oMeasurement_unit = faMeasure.GetByPrimaryKey(new CMeasurement_unitKeys(Convert.ToInt16(oMr_detail.Idunit1))); tbUnitMeasure.Text = oMeasurement_unit.Name_unit; #endregion // --- clear columns gcBachCalc.DataSource = null; // --- format the datatable with the number of repetitions if (cbAuthorizationApproved.EditValue.ToString() == "0000") oDataBatch = new CDataBatch(Idbatch, Idtemplate_method, Comun.StatusWork.Saved, Comun.CriteriaSort.BySample); else oDataBatch = new CDataBatch(Idbatch, Idtemplate_method, Comun.StatusWork.Management, Comun.CriteriaSort.BySample); gcBachCalc.DataSource = oDataBatch.ListSamples; // --- show sd tbAbs.Value = oDataBatch.Absorbance; tbStd.Value = oDataBatch.StdVerification; tbAbs.BackColor = oDataBatch.ColorAbsorbance; tbStd.BackColor = oDataBatch.ColorStd; tbSdBlk.Text = oDataBatch.LrbMeasured.ToString(); tbSdBlk.BackColor = oDataBatch.ColorLrbMeasured; tbSdMr.Text = oDataBatch.MriMeasured.ToString(); tbSdMr.BackColor = oDataBatch.ColorMriMeasured; // --- OPTIMIZAR A USER CONTROL paAuthorization.Visible = true; // --- show empty sample ShowParityEmptySample(true); }
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; } }
public void Review() { try { CBatchFactory faBatch = new CBatchFactory(); CBatch oBatch = faBatch.GetByPrimaryKey(new CBatchKeys(Idbatch)); // --- save trace CRecep_sample_detail_elemFactory faRecep_sample_detail_elem = new CRecep_sample_detail_elemFactory(); for (int i = 0; i < ListSamples.Count; i++) { CBatch_detail_aa_twofold current_row = ListSamples[i]; int status_result = Convert.ToInt32(current_row.Qaqc_status_result); if (Convert.ToInt32(current_row.Flag_mri) == 0) { // --- set how accepted sample // Espera = 0, // Incorrecto = 1, // Plausible = 2, // Aceptado = 3, // IncorrectoPlausible = 4, // Espera reensayos = 5 // --- save only the accept samples long Idrecep_sample_detail_elem = Convert.ToInt64(current_row.Idrecep_sample_detail_elem); if (Convert.ToBoolean(oBatch.Flag_correct_mri) && Convert.ToBoolean(oBatch.Flag_correct_lrb)) { if (status_result == Convert.ToInt32(Comun.Status_result.Plausible)) { current_row.Qaqc_status_result = Convert.ToInt16(Comun.Status_result.Aceptado); } Qaqc oQaqc = new Qaqc(); if (!oQaqc.IsRetest(Idrecep_sample_detail_elem, Idbatch)) { // --- save final element law if (current_row.Qaqc_status_result == Convert.ToInt16(Comun.Status_result.Aceptado)) { CRecep_sample_detail_elem oRecep_sample_detail_elem = faRecep_sample_detail_elem.GetByPrimaryKey(new CRecep_sample_detail_elemKeys(Idrecep_sample_detail_elem)); oRecep_sample_detail_elem.Result_analysis = current_row.Result_analysis; oRecep_sample_detail_elem.Str_result_analysis = current_row.Str_result_analysis.ToString(); oRecep_sample_detail_elem.With_result = true; if (current_row.Str_result_analysis == null) { oRecep_sample_detail_elem.With_result = false; } faRecep_sample_detail_elem.Update(oRecep_sample_detail_elem); } CBatch_detail_aa_twofoldFactory faBatch_detail_aa_twofold = new CBatch_detail_aa_twofoldFactory(); faBatch_detail_aa_twofold.Update(current_row); } else// --- es un reensayo { if (!oQaqc.ExistsResultPendingSel(Idrecep_sample_detail_elem, Idbatch)) { // --- si no está pendiente de seleccionar entre varios análisis // --- save final element law if (current_row.Qaqc_status_result == Convert.ToInt16(Comun.Status_result.Aceptado)) { CRecep_sample_detail_elem oRecep_sample_detail_elem = faRecep_sample_detail_elem.GetByPrimaryKey(new CRecep_sample_detail_elemKeys(Idrecep_sample_detail_elem)); oRecep_sample_detail_elem.Result_analysis = current_row.Result_analysis; oRecep_sample_detail_elem.Str_result_analysis = current_row.Str_result_analysis.ToString(); oRecep_sample_detail_elem.With_result = true; if (current_row.Str_result_analysis == null) { oRecep_sample_detail_elem.With_result = false; } faRecep_sample_detail_elem.Update(oRecep_sample_detail_elem); } CBatch_detail_aa_twofoldFactory faBatch_detail_aa_twofold = new CBatch_detail_aa_twofoldFactory(); faBatch_detail_aa_twofold.Update(current_row); } } // --- save retest if (current_row.Qaqc_tmp_retest == 1) { string cod_type_sample = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(Convert.ToInt32(current_row.Idtemplate_method))).Cod_type_sample; CCorrelative oCorrelative = new CCorrelativeFactory().GetByPrimaryKey(new CCorrelativeKeys(cod_type_sample)); CBatchManager oBatchManager = new CBatchManager(); oBatchManager.CallSaveSampleBatchWithRetest( Convert.ToInt32(current_row.Idtemplate_method), Convert.ToInt64(current_row.Idrecep_sample), Convert.ToInt64(current_row.Idrecep_sample_detail), Convert.ToInt64(current_row.Idrecep_sample_detail_elem), Convert.ToInt64(current_row.Cod_interno), current_row.Cod_sample, Comun.GetUser(), oCorrelative, Convert.ToInt32(current_row.Qaqc_par), Idbatch); } // --- register as finished trace process CProcess_Sample_Manage.Finalize_process(Idrecep_sample_detail_elem, LimsProcess.PROCESS_APPROVE_SAMPLES, LimsProcess.PROCESS_ACCEPT_RESULTS); } else { // --- the samples pertain to batch with full batch retest CProcess_Sample_Manage.Finalize_process(Idrecep_sample_detail_elem, LimsProcess.PROCESS_APPROVE_SAMPLES, LimsProcess.PROCESS_ACCEPT_RESULTS); } } } // --- modify the batch status, put in other process CProcess oProcess = new CProcessFactory().GetByPrimaryKey(new CProcessKeys(LimsProcess.PROCESS_ACCEPT_RESULTS)); oBatch.Status_process = Convert.ToChar(LimsProcess.Status_Process.Waiting); oBatch.Cod_module = oProcess.Cod_module; oBatch.Cod_area = oProcess.Cod_area; oBatch.Cod_process = LimsProcess.PROCESS_ACCEPT_RESULTS; oBatch.User_review_tray = Comun.GetUser(); oBatch.Date_review_tray = Comun.GetDate(); faBatch.Update(oBatch); // --- register as finished trace batch Cprocess_Batch_Manage.Finalize_process(Idbatch, LimsProcess.PROCESS_APPROVE_SAMPLES, LimsProcess.PROCESS_ACCEPT_RESULTS); } catch (Exception ex) { Comun.Save_log(ex.InnerException.ToString()); throw new Exception("pivot data::approve::Error occured.", ex); } }
// --- insert sample in batch public void CallSaveSampleBatch(int idtemplate_method, long idrecep_sample, long idrecep_sample_detail, long idrecep_sample_detail_elem, long cod_interno, string str_cod_interno, string user, CCorrelative correlative) { Correlative = correlative; CBatch_detail_aa_twofold oBatch_detail_aa_twofold = new CBatch_detail_aa_twofold(); CTemplate_method oTemplate_method = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(idtemplate_method)); CTemplate_method_aa oTemplate_method_aa = new CTemplate_method_aaFactory().GetByPrimaryKey(new CTemplate_method_aaKeys(idtemplate_method)); CRecep_sample_detail oRecep_sample_detail = new CRecep_sample_detailFactory().GetByPrimaryKey(new CRecep_sample_detailKeys(idrecep_sample_detail)); CDescription_sample oDescription_sample = new CDescription_sampleFactory().GetByPrimaryKey(new CDescription_sampleKeys(oRecep_sample_detail.Cod_des_sample)); if (oTemplate_method_aa != null) { oBatch_detail_aa_twofold.Idtemplate_method = idtemplate_method; oBatch_detail_aa_twofold.Idrecep_sample = idrecep_sample; oBatch_detail_aa_twofold.Idrecep_sample_detail = idrecep_sample_detail; oBatch_detail_aa_twofold.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; oBatch_detail_aa_twofold.Idunit_result = oTemplate_method_aa.Idunit_result; oBatch_detail_aa_twofold.Weight1 = oTemplate_method_aa.Weight; oBatch_detail_aa_twofold.Weight2 = oTemplate_method_aa.Weight; oBatch_detail_aa_twofold.Volumen1 = oTemplate_method_aa.Volumen; oBatch_detail_aa_twofold.Volumen2 = oTemplate_method_aa.Volumen; oBatch_detail_aa_twofold.Dilu2 = oTemplate_method_aa.Dilution2; oBatch_detail_aa_twofold.Dilu3 = oTemplate_method_aa.Dilution3; oBatch_detail_aa_twofold.Flag_dilu2 = false; oBatch_detail_aa_twofold.Flag_dilu3 = false; oBatch_detail_aa_twofold.Cod_des_sample = oRecep_sample_detail.Cod_des_sample; oBatch_detail_aa_twofold.Order_des_sample = oDescription_sample.Priority_order; oBatch_detail_aa_twofold.Flag_mri = 0; oBatch_detail_aa_twofold.Fum = methods.GetFactorConvertionUM(idtemplate_method); oBatch_detail_aa_twofold.Qaqc_blk = 3; oBatch_detail_aa_twofold.Qaqc_par = 3; oBatch_detail_aa_twofold.Qaqc_mr = 3; oBatch_detail_aa_twofold.Qaqc_error = 0; oBatch_detail_aa_twofold.Qaqc_approve = false; oBatch_detail_aa_twofold.Qaqc_review = false; oBatch_detail_aa_twofold.Qaqc_has_retest = 0; oBatch_detail_aa_twofold.Qaqc_tmp_retest = 0; oBatch_detail_aa_twofold.Qaqc_tmp_retest_idmethod = 0; oBatch_detail_aa_twofold.Qaqc_approve_text = ""; oBatch_detail_aa_twofold.Qaqc_review_text = ""; oBatch_detail_aa_twofold.Cod_interno = cod_interno; oBatch_detail_aa_twofold.Cod_sample = str_cod_interno; // --- control sample control_sample.Idtemplate_method = idtemplate_method; //control_sample.Idrecep_sample = idrecep_sample; //control_sample.Idrecep_sample_detail = idrecep_sample_detail; //control_sample.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; control_sample.Weight1 = oTemplate_method_aa.Weight; control_sample.Weight2 = oTemplate_method_aa.Weight; control_sample.Volumen1 = oTemplate_method_aa.Volumen; control_sample.Volumen2 = oTemplate_method_aa.Volumen; control_sample.Dilu2 = oTemplate_method_aa.Dilution2; control_sample.Dilu3 = oTemplate_method_aa.Dilution3; control_sample.Flag_dilu2 = false; control_sample.Flag_dilu3 = false; control_sample.Flag_mri = 1; control_sample.Fum = methods.GetFactorConvertionUM(idtemplate_method); control_sample.Qaqc_blk = 3; control_sample.Qaqc_par = 3; control_sample.Qaqc_mr = 3; control_sample.Qaqc_error = 0; control_sample.Qaqc_approve = false; control_sample.Qaqc_review = false; control_sample.Qaqc_tmp_retest_idmethod = 0; control_sample.Qaqc_approve_text = ""; control_sample.Qaqc_review_text = ""; SaveInBatch(oBatch_detail_aa_twofold, user); } }
bool SaveAA() { try { string Cod_method = gluCod_method.Text; string Title = tbTitle.Text; string messageOk = ""; Methods oMethods = new Methods(); Comun.MethodSaveProperty InspectionChanges = RequireNewVersionOrMethod(Comun.GetTypeAnalysis(Convert.ToChar(cbTypeAnalysis.EditValue))); if (InspectionChanges == Comun.MethodSaveProperty.NewMethod) { Num_version = 1; messageOk = "Se guardó un nuevo método con código " + Cod_method + "\ncon título " + Title; } if (InspectionChanges == Comun.MethodSaveProperty.InspectionNewVersion) { // --- save as new version or overwrite FormConfirmSaveMethod fmConfirmSaveMethod = new FormConfirmSaveMethod(true); if (fmConfirmSaveMethod.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (fmConfirmSaveMethod.SaveType == Comun.Save_type.SaveAs) { FormMethodSaveAs fmMethodSaveAs = new FormMethodSaveAs(); fmMethodSaveAs.ListTemplate = oMethods.GetAllLastVersionMethods( Convert.ToInt32(cbElement.EditValue), cbTypeSample.EditValue.ToString(), Convert.ToChar(cbTypeAnalysis.EditValue)); if (fmMethodSaveAs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Num_version = 1; IDTemplate_Method = 0; Cod_method = fmMethodSaveAs.Cod_method; Title = fmMethodSaveAs.Title; messageOk = "Se guardó un nuevo método con código " + fmMethodSaveAs.Cod_method + "\n con título '" + fmMethodSaveAs.Title + "'"; } else { return(false); } } if (fmConfirmSaveMethod.SaveType == Comun.Save_type.Save) { Num_version = oMethods.GetNumNewVersion(IDTemplate_Method); IDTemplate_Method = 0; messageOk = "Se guardó una nueva versión [" + Num_version.ToString() + "] del método " + Cod_method; } } else { return(false); } } if (InspectionChanges == Comun.MethodSaveProperty.InspectionNewMethod) { FormMethodSaveAs fmMethodSaveAs = new FormMethodSaveAs(); fmMethodSaveAs.ListTemplate = oMethods.GetAllLastVersionMethods( Convert.ToInt32(cbElement.EditValue), cbTypeSample.EditValue.ToString(), Convert.ToChar(cbTypeAnalysis.EditValue)); if (fmMethodSaveAs.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Num_version = 1; IDTemplate_Method = 0; Cod_method = fmMethodSaveAs.Cod_method; Title = fmMethodSaveAs.Title; messageOk = "Se guardó un nuevo método con código " + fmMethodSaveAs.Cod_method + "\n con título " + fmMethodSaveAs.Title; } else { return(false); } } if (InspectionChanges == Comun.MethodSaveProperty.Nothing) { messageOk = "Se guardó correctamente"; } // --- save head CTemplate_methodFactory faTemplate_Method = new CTemplate_methodFactory(); CTemplate_method oTemplate_Method = new CTemplate_method(); oTemplate_Method.Idtemplate_method = IDTemplate_Method; oTemplate_Method.Num_version = Num_version; oTemplate_Method.Idelement = Convert.ToInt32(cbElement.EditValue); oTemplate_Method.Cod_template_method = Cod_method; oTemplate_Method.Title = Title; oTemplate_Method.Cod_digestion_method = cbDigestion.EditValue.ToString(); oTemplate_Method.Cod_repetition = Convert.ToInt16(cbRepetition.EditValue); oTemplate_Method.Abbreviation = tbAbreviation.Text; oTemplate_Method.Recognized = ckRecognized.Checked; oTemplate_Method.Cod_type_sample = cbTypeSample.EditValue.ToString(); oTemplate_Method.Cost_method = tbCost_Method.Value; oTemplate_Method.Type_analisys = Convert.ToChar(cbTypeAnalysis.EditValue); oTemplate_Method.Status = true; if (IDTemplate_Method == 0) { oTemplate_Method.Usernew = Comun.GetUser(); oTemplate_Method.Datenew = Comun.GetDate(); oTemplate_Method.Useredit = Comun.GetUser(); oTemplate_Method.Dateedit = Comun.GetDate(); } else { oTemplate_Method.Useredit = Comun.GetUser(); oTemplate_Method.Dateedit = Comun.GetDate(); } bool result_template_method = false; if (!(result_template_method = faTemplate_Method.Update(oTemplate_Method))) { result_template_method = faTemplate_Method.Insert(oTemplate_Method); } if (result_template_method) { IDTemplate_Method = oTemplate_Method.Idtemplate_method; SaveTypeAnalysis(); } FormResult fmResult = new FormResult(); fmResult.Message = messageOk; fmResult.ShowDialog(); gluCod_method.Text = Cod_method; return(true); } catch (Exception ex) { ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message); return(false); } }
public void Review() { try { CBatchFactory faBatch = new CBatchFactory(); CBatch oBatch = faBatch.GetByPrimaryKey(new CBatchKeys(Idbatch)); // --- save trace CRecep_sample_detail_elemFactory faRecep_sample_detail_elem = new CRecep_sample_detail_elemFactory(); for (int i = 0; i < ListSamples.Count; i++) { CBatch_detail_aa_twofold current_row = ListSamples[i]; int status_result = Convert.ToInt32(current_row.Qaqc_status_result); if (Convert.ToInt32(current_row.Flag_mri) == 0) { // --- set how accepted sample // Espera = 0, // Incorrecto = 1, // Plausible = 2, // Aceptado = 3, // IncorrectoPlausible = 4, // Espera reensayos = 5 // --- save only the accept samples long Idrecep_sample_detail_elem = Convert.ToInt64(current_row.Idrecep_sample_detail_elem); if (Convert.ToBoolean(oBatch.Flag_correct_mri) && Convert.ToBoolean(oBatch.Flag_correct_lrb)) { if (status_result == Convert.ToInt32(Comun.Status_result.Plausible)) current_row.Qaqc_status_result = Convert.ToInt16(Comun.Status_result.Aceptado); Qaqc oQaqc = new Qaqc(); if (!oQaqc.IsRetest(Idrecep_sample_detail_elem, Idbatch)) { // --- save final element law if (current_row.Qaqc_status_result == Convert.ToInt16(Comun.Status_result.Aceptado)) { CRecep_sample_detail_elem oRecep_sample_detail_elem = faRecep_sample_detail_elem.GetByPrimaryKey(new CRecep_sample_detail_elemKeys(Idrecep_sample_detail_elem)); oRecep_sample_detail_elem.Result_analysis = current_row.Result_analysis; oRecep_sample_detail_elem.Str_result_analysis = current_row.Str_result_analysis.ToString(); oRecep_sample_detail_elem.With_result = true; if (current_row.Str_result_analysis == null) oRecep_sample_detail_elem.With_result = false; faRecep_sample_detail_elem.Update(oRecep_sample_detail_elem); } CBatch_detail_aa_twofoldFactory faBatch_detail_aa_twofold = new CBatch_detail_aa_twofoldFactory(); faBatch_detail_aa_twofold.Update(current_row); } else// --- es un reensayo { if (!oQaqc.ExistsResultPendingSel(Idrecep_sample_detail_elem, Idbatch)) { // --- si no está pendiente de seleccionar entre varios análisis // --- save final element law if (current_row.Qaqc_status_result == Convert.ToInt16(Comun.Status_result.Aceptado)) { CRecep_sample_detail_elem oRecep_sample_detail_elem = faRecep_sample_detail_elem.GetByPrimaryKey(new CRecep_sample_detail_elemKeys(Idrecep_sample_detail_elem)); oRecep_sample_detail_elem.Result_analysis = current_row.Result_analysis; oRecep_sample_detail_elem.Str_result_analysis = current_row.Str_result_analysis.ToString(); oRecep_sample_detail_elem.With_result = true; if (current_row.Str_result_analysis == null) oRecep_sample_detail_elem.With_result = false; faRecep_sample_detail_elem.Update(oRecep_sample_detail_elem); } CBatch_detail_aa_twofoldFactory faBatch_detail_aa_twofold = new CBatch_detail_aa_twofoldFactory(); faBatch_detail_aa_twofold.Update(current_row); } } // --- save retest if (current_row.Qaqc_tmp_retest == 1) { string cod_type_sample = new CTemplate_methodFactory().GetByPrimaryKey(new CTemplate_methodKeys(Convert.ToInt32(current_row.Idtemplate_method))).Cod_type_sample; CCorrelative oCorrelative = new CCorrelativeFactory().GetByPrimaryKey(new CCorrelativeKeys(cod_type_sample)); CBatchManager oBatchManager = new CBatchManager(); oBatchManager.CallSaveSampleBatchWithRetest( Convert.ToInt32(current_row.Idtemplate_method), Convert.ToInt64(current_row.Idrecep_sample), Convert.ToInt64(current_row.Idrecep_sample_detail), Convert.ToInt64(current_row.Idrecep_sample_detail_elem), Convert.ToInt64(current_row.Cod_interno), current_row.Cod_sample, Comun.GetUser(), oCorrelative, Convert.ToInt32(current_row.Qaqc_par), Idbatch); } // --- register as finished trace process CProcess_Sample_Manage.Finalize_process(Idrecep_sample_detail_elem, LimsProcess.PROCESS_APPROVE_SAMPLES, LimsProcess.PROCESS_ACCEPT_RESULTS); } else { // --- the samples pertain to batch with full batch retest CProcess_Sample_Manage.Finalize_process(Idrecep_sample_detail_elem, LimsProcess.PROCESS_APPROVE_SAMPLES, LimsProcess.PROCESS_ACCEPT_RESULTS); } } } // --- modify the batch status, put in other process CProcess oProcess = new CProcessFactory().GetByPrimaryKey(new CProcessKeys(LimsProcess.PROCESS_ACCEPT_RESULTS)); oBatch.Status_process = Convert.ToChar(LimsProcess.Status_Process.Waiting); oBatch.Cod_module = oProcess.Cod_module; oBatch.Cod_area = oProcess.Cod_area; oBatch.Cod_process = LimsProcess.PROCESS_ACCEPT_RESULTS; oBatch.User_review_tray = Comun.GetUser(); oBatch.Date_review_tray = Comun.GetDate(); faBatch.Update(oBatch); // --- register as finished trace batch Cprocess_Batch_Manage.Finalize_process(Idbatch, LimsProcess.PROCESS_APPROVE_SAMPLES, LimsProcess.PROCESS_ACCEPT_RESULTS); } catch (Exception ex) { Comun.Save_log(ex.InnerException.ToString()); throw new Exception("pivot data::approve::Error occured.", ex); } }