protected override void Limpiar_Campos() { oReactive = null; cbFormula.EditValue = null; tbName.Text = ""; tbWeightMolecular.Value = 0; cbFormula.Focus(); cbFormula.Select(); }
protected override void Limpiar_Campos() { oReactive = null; cbFormula.EditValue = null; tbName.Text = ""; tbWeightMolecular.Value = 0; cbFormula.Focus(); cbFormula.Select(); }
protected override void Recuperar_Registro() { CReactiveFactory faReactive = new CReactiveFactory(); oReactive = faReactive.GetByPrimaryKey(new CReactiveKeys(Convert.ToInt32(cbFormula.EditValue))); if (oReactive != null) { tbName.Text = oReactive.Reactive_name; tbWeightMolecular.Value = Convert.ToDecimal(oReactive.Weight_molecular); } }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CReactive</returns> internal List <CReactive> PopulateObjectsFromReader(IDataReader dataReader) { List <CReactive> list = new List <CReactive>(); while (dataReader.Read()) { CReactive businessObject = new CReactive(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override void Recuperar_Registro() { CReactiveFactory faReactive = new CReactiveFactory(); oReactive = faReactive.GetByPrimaryKey(new CReactiveKeys(Convert.ToInt32(cbFormula.EditValue))); if (oReactive != null) { tbName.Text = oReactive.Reactive_name; tbWeightMolecular.Value = Convert.ToDecimal(oReactive.Weight_molecular); } }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CReactive businessObject, IDataReader dataReader) { businessObject.Idreactive = dataReader.GetInt32(dataReader.GetOrdinal(CReactive.CReactiveFields.Idreactive.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CReactive.CReactiveFields.Reactive_name.ToString()))) { businessObject.Reactive_name = dataReader.GetString(dataReader.GetOrdinal(CReactive.CReactiveFields.Reactive_name.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CReactive.CReactiveFields.Chemical_formula.ToString()))) { businessObject.Chemical_formula = dataReader.GetString(dataReader.GetOrdinal(CReactive.CReactiveFields.Chemical_formula.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CReactive.CReactiveFields.Weight_molecular.ToString()))) { businessObject.Weight_molecular = dataReader.GetDecimal(dataReader.GetOrdinal(CReactive.CReactiveFields.Weight_molecular.ToString())); } }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CReactive business object</returns> public CReactive SelectByPrimaryKey(CReactiveKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_reactive_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_idreactive", NpgsqlDbType.Integer, 4, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idreactive)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CReactive businessObject = new CReactive(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CReactive::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
private void cbNomReactives_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 <CReactive> lstReactives = (List <CReactive>)cbFormula.Properties.DataSource; CReactive oReactive = new CReactive(); oReactive.Idreactive = 0; oReactive.Chemical_formula = cbFormula.Text; lstReactives.Add(oReactive); cbFormula.Properties.DataSource = lstReactives; e.Handled = true; }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(CReactive businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_reactive_Insert"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_idreactive", businessObject.Idreactive); sqlCommand.Parameters["p_idreactive"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters["p_idreactive"].Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.AddWithValue("p_reactive_name", businessObject.Reactive_name); sqlCommand.Parameters["p_reactive_name"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_chemical_formula", businessObject.Chemical_formula); sqlCommand.Parameters["p_chemical_formula"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_weight_molecular", businessObject.Weight_molecular); sqlCommand.Parameters["p_weight_molecular"].NpgsqlDbType = NpgsqlDbType.Numeric; MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.Idreactive = Convert.ToInt32(sqlCommand.Parameters["p_idreactive"].Value); return(true); } catch (Exception ex) { throw new Exception("CReactive::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
protected override bool Grabar_Registro() { CReactiveFactory faReactive = new CReactiveFactory(); if (oReactive == null) { oReactive = new CReactive(); oReactive.Idreactive = 0; } oReactive.Reactive_name = tbName.Text; oReactive.Chemical_formula = cbFormula.Text; oReactive.Weight_molecular = tbWeightMolecular.Value; bool result = false; if (!(result= faReactive.Update(oReactive))) result = faReactive.Insert(oReactive); return result; }
protected override bool Grabar_Registro() { CReactiveFactory faReactive = new CReactiveFactory(); if (oReactive == null) { oReactive = new CReactive(); oReactive.Idreactive = 0; } oReactive.Reactive_name = tbName.Text; oReactive.Chemical_formula = cbFormula.Text; oReactive.Weight_molecular = tbWeightMolecular.Value; bool result = false; if (!(result = faReactive.Update(oReactive))) { result = faReactive.Insert(oReactive); } return(result); }
private void cbNomReactives_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<CReactive> lstReactives = (List<CReactive>)cbFormula.Properties.DataSource; CReactive oReactive = new CReactive(); oReactive.Idreactive = 0; oReactive.Chemical_formula = cbFormula.Text; lstReactives.Add(oReactive); cbFormula.Properties.DataSource = lstReactives; e.Handled = true; }