//public BindingList<CSolution> GetLstChildSolution(int idsolution) //{ // List<CSolution> lst = new CSolutionFactory() // .GetAll().Where(c => c.Idpattern == idsolution && c.Status == true).ToList(); // return new BindingList<CSolution>(lst); //} //public BindingList<CSolution> GetLstChildMr(short idmr) //{ // List<CSolution> lst = new CSolutionFactory() // .GetAll().Where(c => c.Idpattern_mr == idmr && c.Status == true).ToList(); // return new BindingList<CSolution>(lst); //} public decimal?GetConcentrationPPM(short idmr_detail) { CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = faMr_detail.GetByPrimaryKey(new CMr_detailKeys(idmr_detail)); CSettings oSettings = new CSettings(); CConvert_unit_measurementFactory faCConvert_unit_measurement = new CConvert_unit_measurementFactory(); var query = ( from t in faCConvert_unit_measurement.GetAll() where t.Idunit2 == oSettings.GetUnitMeasureSolution() && t.Idunit1 == oMr_detail.Idunit1 select new { Concentration = oMr_detail.Nominal_value * t.Factor }).ToList(); foreach (var item in query) { if (item.Concentration != null) { return(Math.Round(Convert.ToDecimal(item.Concentration), 4)); } } decimal?num = null; return(num); }
private void cbCod_method_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit Edit; Edit = ((DevExpress.XtraEditors.LookUpEdit)sender).Properties; if (e.DisplayValue == null || Edit.NullText.Equals(e.DisplayValue) || string.Empty.Equals(e.DisplayValue)) { return; } List <CMr> lstMr = (List <CMr>)cbCodMR.Properties.DataSource; CMr oMr = new CMr(); oMr.Cod_mr = e.DisplayValue.ToString(); oMr.Idmr = -100; lstMr.Add(oMr); cbCodMR.Properties.DataSource = lstMr; // --- referencia material detail CMr_detail oMr_detail = new CMr_detail(); CMr_detailFactory faMr_detail = new CMr_detailFactory(); BindingList <CMr_detail> lstMr_detail = new BindingList <CMr_detail>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().SelectByMr(0)); gcMaterialReference.DataSource = lstMr_detail; // --- jar detail CMr_jarFactory faMr_jar = new CMr_jarFactory(); CMr_jar oMr_jar = new CMr_jar(); BindingList <CMr_jar> lstMr_jar = new BindingList <CMr_jar>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().GetJarByMr(0)); gcOpenCloseJar.DataSource = lstMr_jar; e.Handled = true; }
protected override void Recuperar_Registro() { CMr oMr = new CMr(); CMrFactory faMr = new CMrFactory(); if ((oMr = faMr.GetByPrimaryKey(new CMrKeys(IDMr))) != null) { tbLot.Text = oMr.Lot; cbTypeMr.EditValue = Convert.ToChar(oMr.Type_mr); cbDescription.EditValue = oMr.Type_material; cbManufacturer.EditValue = oMr.Manufaturer; cbCertifier.EditValue = oMr.Certifier; cbStatus.EditValue = oMr.Status_mr; deBegin.DateTime = Convert.ToDateTime(oMr.Fbegin_validity); deEnd.DateTime = Convert.ToDateTime(oMr.Fend_validity); CMr_detail oMr_detail = new CMr_detail(); CMr_detailFactory faMr_detail = new CMr_detailFactory(); BindingList <CMr_detail> lstMr_detail = new BindingList <CMr_detail>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().SelectByMr(oMr.Idmr)); gcMaterialReference.DataSource = lstMr_detail; CMr_jarFactory faMr_jar = new CMr_jarFactory(); CMr_jar oMr_jar = new CMr_jar(); BindingList <CMr_jar> lstMr_jar = new BindingList <CMr_jar>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().GetJarByMr(IDMr)); gcOpenCloseJar.DataSource = lstMr_jar; } }
private void cbMaterialRef_EditValueChanged(object sender, EventArgs e) { CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = faMr_detail.GetByPrimaryKey( new CMr_detailKeys(Convert.ToInt16(cbMaterialRef.EditValue))); if (oMr_detail != null) { tbLawMri.Text = oMr_detail.Nominal_value.ToString(); } }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CMr_detail</returns> internal List <CMr_detail> PopulateObjectsFromReader(IDataReader dataReader) { List <CMr_detail> list = new List <CMr_detail>(); while (dataReader.Read()) { CMr_detail businessObject = new CMr_detail(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CMr_detail business object</returns> public CMr_detail SelectByPrimaryKey(CMr_detailKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_mr_detail_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_idmr_detail", NpgsqlDbType.Smallint, 2, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idmr_detail)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CMr_detail businessObject = new CMr_detail(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CMr_detail::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
public void InitConfiguration() { Mri_measured = 0; Lrb_measured = 0; Flag_correct_mri = null; Flag_correct_lrb = null; CTemplate_method_aaFactory faTemplate_method_aa = new CTemplate_method_aaFactory(); oTemplate_method_aa = faTemplate_method_aa.GetByPrimaryKey(new CTemplate_method_aaKeys(Idtemplate_method)); Max_value_blk = Convert.ToDecimal(oTemplate_method_aa.Blk_max); Factor_repetibility = Convert.ToDecimal(oTemplate_method_aa.Reason_rep); Factor_reproducibility = Convert.ToDecimal(oTemplate_method_aa.Reproducibility); CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = faMr_detail.GetByPrimaryKey(new CMr_detailKeys(Convert.ToInt16(oTemplate_method_aa.Idmr_detail))); Law_fixed = Convert.ToDecimal(oMr_detail.Nominal_value); }
protected override bool Grabar_Registro() { bool result = false; try { CMrFactory faMr = new CMrFactory(); CMr oMr = new CMr(); oMr.Cod_mr = cbCodMR.Text; oMr.Idmr = IDMr; oMr.Lot = tbLot.Text; oMr.Type_material = Convert.ToChar(cbDescription.EditValue); oMr.Type_mr = Convert.ToChar(cbTypeMr.EditValue); oMr.Status_mr = Convert.ToBoolean(cbStatus.EditValue); oMr.Type_material = Convert.ToChar(cbDescription.EditValue); oMr.Manufaturer = Convert.ToInt16(cbManufacturer.EditValue); oMr.Certifier = Convert.ToInt16(cbCertifier.EditValue); oMr.Fbegin_validity = deBegin.DateTime; oMr.Fend_validity = deEnd.DateTime; if (!(result = faMr.Update(oMr))) result = faMr.Insert(oMr); if (result) { IDMr = oMr.Idmr; // --- detail elements CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = new CMr_detail(); for (int i = 0; i < gvMaterialReference.RowCount; i++) { oMr_detail = (CMr_detail)gvMaterialReference.GetRow(i); oMr_detail.Idmr = IDMr; if (!faMr_detail.Update(oMr_detail)) faMr_detail.Insert(oMr_detail); } // --- detail jars CMr_jarFactory faMr_jar = new CMr_jarFactory(); CMr_jar oMr_jar = new CMr_jar(); for (int i = 0; i < gvOpenCloseJar.RowCount; i++) { oMr_jar = (CMr_jar)gvOpenCloseJar.GetRow(i); oMr_jar.Idmr = IDMr; if (!faMr_jar.Update(oMr_jar)) faMr_jar.Insert(oMr_jar); } } } catch (Exception ex) { result = false; ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message); } return result; }
private void cbCod_method_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit Edit; Edit = ((DevExpress.XtraEditors.LookUpEdit)sender).Properties; if (e.DisplayValue == null || Edit.NullText.Equals(e.DisplayValue) || string.Empty.Equals(e.DisplayValue)) { return; } List<CMr> lstMr = (List<CMr>)cbCodMR.Properties.DataSource; CMr oMr = new CMr(); oMr.Cod_mr = e.DisplayValue.ToString(); oMr.Idmr = -100; lstMr.Add(oMr); cbCodMR.Properties.DataSource = lstMr; // --- referencia material detail CMr_detail oMr_detail = new CMr_detail(); CMr_detailFactory faMr_detail = new CMr_detailFactory(); BindingList<CMr_detail> lstMr_detail = new BindingList<CMr_detail>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().SelectByMr(0)); gcMaterialReference.DataSource = lstMr_detail; // --- jar detail CMr_jarFactory faMr_jar = new CMr_jarFactory(); CMr_jar oMr_jar = new CMr_jar(); BindingList<CMr_jar> lstMr_jar = new BindingList<CMr_jar>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().GetJarByMr(0)); gcOpenCloseJar.DataSource = lstMr_jar; e.Handled = true; }
protected override void Recuperar_Registro() { CMr oMr = new CMr(); CMrFactory faMr = new CMrFactory(); if ((oMr = faMr.GetByPrimaryKey(new CMrKeys(IDMr))) != null) { tbLot.Text = oMr.Lot; cbTypeMr.EditValue = Convert.ToChar(oMr.Type_mr); cbDescription.EditValue = oMr.Type_material; cbManufacturer.EditValue = oMr.Manufaturer; cbCertifier.EditValue = oMr.Certifier; cbStatus.EditValue = oMr.Status_mr; deBegin.DateTime = Convert.ToDateTime(oMr.Fbegin_validity); deEnd.DateTime = Convert.ToDateTime(oMr.Fend_validity); CMr_detail oMr_detail = new CMr_detail(); CMr_detailFactory faMr_detail = new CMr_detailFactory(); BindingList<CMr_detail> lstMr_detail = new BindingList<CMr_detail>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().SelectByMr(oMr.Idmr)); gcMaterialReference.DataSource = lstMr_detail; CMr_jarFactory faMr_jar = new CMr_jarFactory(); CMr_jar oMr_jar = new CMr_jar(); BindingList<CMr_jar> lstMr_jar = new BindingList<CMr_jar>(new LimsProject.BusinessLayer.Modules.ModMaterialReference().GetJarByMr(IDMr)); gcOpenCloseJar.DataSource = lstMr_jar; } }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CMr_detail businessObject, IDataReader dataReader) { businessObject.Idmr_detail = (short)dataReader.GetInt16(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Idmr_detail.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Idmr.ToString()))) { businessObject.Idmr = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Idmr.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Analyte.ToString()))) { businessObject.Analyte = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Analyte.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Cod_element.ToString()))) { businessObject.Cod_element = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Cod_element.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Nom_detail.ToString()))) { businessObject.Nom_detail = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Nom_detail.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Incertitude.ToString()))) { businessObject.Incertitude = dataReader.GetDecimal(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Incertitude.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Nominal_value.ToString()))) { businessObject.Nominal_value = dataReader.GetDecimal(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Nominal_value.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Idunit1.ToString()))) { businessObject.Idunit1 = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Idunit1.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Document_ref.ToString()))) { businessObject.Document_ref = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Document_ref.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Dev.ToString()))) { businessObject.Dev = dataReader.GetDecimal(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Dev.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Dev_labs.ToString()))) { businessObject.Dev_labs = dataReader.GetDecimal(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Dev_labs.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Flag_provitional.ToString()))) { businessObject.Flag_provitional = dataReader.GetBoolean(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Flag_provitional.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Cod_digestion_method.ToString()))) { businessObject.Cod_digestion_method = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Cod_digestion_method.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Observation.ToString()))) { businessObject.Observation = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Observation.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Usernew.ToString()))) { businessObject.Usernew = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Usernew.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Datenew.ToString()))) { businessObject.Datenew = dataReader.GetDateTime(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Datenew.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Useredit.ToString()))) { businessObject.Useredit = dataReader.GetString(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Useredit.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Dateedit.ToString()))) { businessObject.Dateedit = dataReader.GetDateTime(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Dateedit.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Status.ToString()))) { businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CMr_detail.CMr_detailFields.Status.ToString())); } }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(CMr_detail businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_mr_detail_Insert"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_idmr_detail", businessObject.Idmr_detail); sqlCommand.Parameters["p_idmr_detail"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters["p_idmr_detail"].Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.AddWithValue("p_idmr", businessObject.Idmr); sqlCommand.Parameters["p_idmr"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters.AddWithValue("p_analyte", businessObject.Analyte); sqlCommand.Parameters["p_analyte"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters.AddWithValue("p_cod_element", businessObject.Cod_element); sqlCommand.Parameters["p_cod_element"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_nom_detail", businessObject.Nom_detail); sqlCommand.Parameters["p_nom_detail"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_incertitude", businessObject.Incertitude); sqlCommand.Parameters["p_incertitude"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_nominal_value", businessObject.Nominal_value); sqlCommand.Parameters["p_nominal_value"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_idunit1", businessObject.Idunit1); sqlCommand.Parameters["p_idunit1"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters.AddWithValue("p_document_ref", businessObject.Document_ref); sqlCommand.Parameters["p_document_ref"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_dev", businessObject.Dev); sqlCommand.Parameters["p_dev"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_dev_labs", businessObject.Dev_labs); sqlCommand.Parameters["p_dev_labs"].NpgsqlDbType = NpgsqlDbType.Numeric; sqlCommand.Parameters.AddWithValue("p_flag_provitional", businessObject.Flag_provitional); sqlCommand.Parameters["p_flag_provitional"].NpgsqlDbType = NpgsqlDbType.Boolean; sqlCommand.Parameters.AddWithValue("p_cod_digestion_method", businessObject.Cod_digestion_method); sqlCommand.Parameters["p_cod_digestion_method"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_observation", businessObject.Observation); sqlCommand.Parameters["p_observation"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_usernew", businessObject.Usernew); sqlCommand.Parameters["p_usernew"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_datenew", businessObject.Datenew); sqlCommand.Parameters["p_datenew"].NpgsqlDbType = NpgsqlDbType.Date; sqlCommand.Parameters.AddWithValue("p_useredit", businessObject.Useredit); sqlCommand.Parameters["p_useredit"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_dateedit", businessObject.Dateedit); sqlCommand.Parameters["p_dateedit"].NpgsqlDbType = NpgsqlDbType.Date; sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status); sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean; MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.Idmr_detail = Convert.ToInt16(sqlCommand.Parameters["p_idmr_detail"].Value); return(true); } catch (Exception ex) { throw new Exception("CMr_detail::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
protected override bool Grabar_Registro() { bool result = false; try { CMrFactory faMr = new CMrFactory(); CMr oMr = new CMr(); oMr.Cod_mr = cbCodMR.Text; oMr.Idmr = IDMr; oMr.Lot = tbLot.Text; oMr.Type_material = Convert.ToChar(cbDescription.EditValue); oMr.Type_mr = Convert.ToChar(cbTypeMr.EditValue); oMr.Status_mr = Convert.ToBoolean(cbStatus.EditValue); oMr.Type_material = Convert.ToChar(cbDescription.EditValue); oMr.Manufaturer = Convert.ToInt16(cbManufacturer.EditValue); oMr.Certifier = Convert.ToInt16(cbCertifier.EditValue); oMr.Fbegin_validity = deBegin.DateTime; oMr.Fend_validity = deEnd.DateTime; if (!(result = faMr.Update(oMr))) { result = faMr.Insert(oMr); } if (result) { IDMr = oMr.Idmr; // --- detail elements CMr_detailFactory faMr_detail = new CMr_detailFactory(); CMr_detail oMr_detail = new CMr_detail(); for (int i = 0; i < gvMaterialReference.RowCount; i++) { oMr_detail = (CMr_detail)gvMaterialReference.GetRow(i); oMr_detail.Idmr = IDMr; if (!faMr_detail.Update(oMr_detail)) { faMr_detail.Insert(oMr_detail); } } // --- detail jars CMr_jarFactory faMr_jar = new CMr_jarFactory(); CMr_jar oMr_jar = new CMr_jar(); for (int i = 0; i < gvOpenCloseJar.RowCount; i++) { oMr_jar = (CMr_jar)gvOpenCloseJar.GetRow(i); oMr_jar.Idmr = IDMr; if (!faMr_jar.Update(oMr_jar)) { faMr_jar.Insert(oMr_jar); } } } } catch (Exception ex) { result = false; ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message); } return(result); }