protected override void Recuperar_Registro() { CDigestion_methodFactory faDigestion_Method = new CDigestion_methodFactory(); CDigestion_method oDigestion_Method = new CDigestion_method(); oDigestion_Method = faDigestion_Method.GetByPrimaryKey(new CDigestion_methodKeys("")); if (oDigestion_Method != null) { tbCodDigestion.Text = oDigestion_Method.Cod_digestion_method; tbNameDigestion.Text = oDigestion_Method.Name_digestion_method; } }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CDigestion_method</returns> internal List <CDigestion_method> PopulateObjectsFromReader(IDataReader dataReader) { List <CDigestion_method> list = new List <CDigestion_method>(); while (dataReader.Read()) { CDigestion_method businessObject = new CDigestion_method(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override bool Grabar_Registro() { CDigestion_methodFactory faDigestion_Method = new CDigestion_methodFactory(); CDigestion_method oDigestion_Method = new CDigestion_method(); oDigestion_Method.Cod_digestion_method = tbCodDigestion.Text; oDigestion_Method.Name_digestion_method = tbNameDigestion.Text; bool result = false; if (!(result = faDigestion_Method.Update(oDigestion_Method))) result = faDigestion_Method.Insert(oDigestion_Method); return result; }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CDigestion_method businessObject, IDataReader dataReader) { businessObject.Cod_digestion_method = dataReader.GetString(dataReader.GetOrdinal(CDigestion_method.CDigestion_methodFields.Cod_digestion_method.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CDigestion_method.CDigestion_methodFields.Name_digestion_method.ToString()))) { businessObject.Name_digestion_method = dataReader.GetString(dataReader.GetOrdinal(CDigestion_method.CDigestion_methodFields.Name_digestion_method.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CDigestion_method.CDigestion_methodFields.Status.ToString()))) { businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CDigestion_method.CDigestion_methodFields.Status.ToString())); } }
protected override bool Grabar_Registro() { CDigestion_methodFactory faDigestion_Method = new CDigestion_methodFactory(); CDigestion_method oDigestion_Method = new CDigestion_method(); oDigestion_Method.Cod_digestion_method = tbCodDigestion.Text; oDigestion_Method.Name_digestion_method = tbNameDigestion.Text; bool result = false; if (!(result = faDigestion_Method.Update(oDigestion_Method))) { result = faDigestion_Method.Insert(oDigestion_Method); } return(result); }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CDigestion_method business object</returns> public CDigestion_method SelectByPrimaryKey(CDigestion_methodKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_digestion_method_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_cod_digestion_method", NpgsqlDbType.Varchar, 5, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Cod_digestion_method)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CDigestion_method businessObject = new CDigestion_method(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CDigestion_method::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// update row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true for successfully updated</returns> public bool Update(CDigestion_method businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_digestion_method_Update"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_cod_digestion_method", businessObject.Cod_digestion_method); sqlCommand.Parameters["p_cod_digestion_method"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_name_digestion_method", businessObject.Name_digestion_method); sqlCommand.Parameters["p_name_digestion_method"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status); sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean; MainConnection.Open(); if (Convert.ToInt32(sqlCommand.ExecuteScalar()) > 0) { return(true); } return(false); } catch (Exception ex) { throw new Exception("CDigestion_method::Update::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }