/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(CSet_methods_calib businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_set_methods_calib_Insert"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_idset_methods_calib", businessObject.Idset_methods_calib); sqlCommand.Parameters["p_idset_methods_calib"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters["p_idset_methods_calib"].Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.AddWithValue("p_idsolution_pattern", businessObject.Idsolution_pattern); sqlCommand.Parameters["p_idsolution_pattern"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_idelement", businessObject.Idelement); sqlCommand.Parameters["p_idelement"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_idmr_detail", businessObject.Idmr_detail); sqlCommand.Parameters["p_idmr_detail"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters.AddWithValue("p_idreactive_medium", businessObject.Idreactive_medium); sqlCommand.Parameters["p_idreactive_medium"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_idreactive_modif", businessObject.Idreactive_modif); sqlCommand.Parameters["p_idreactive_modif"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_order_set", businessObject.Order_set); sqlCommand.Parameters["p_order_set"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_name_methods_calib", businessObject.Name_methods_calib); sqlCommand.Parameters["p_name_methods_calib"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_user_calib", businessObject.User_calib); sqlCommand.Parameters["p_user_calib"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters.AddWithValue("p_date_calib", businessObject.Date_calib); sqlCommand.Parameters["p_date_calib"].NpgsqlDbType = NpgsqlDbType.Timestamp; sqlCommand.Parameters.AddWithValue("p_status_set", businessObject.Status_set); sqlCommand.Parameters["p_status_set"].NpgsqlDbType = NpgsqlDbType.Integer; sqlCommand.Parameters.AddWithValue("p_date_ini", businessObject.Date_ini); sqlCommand.Parameters["p_date_ini"].NpgsqlDbType = NpgsqlDbType.Timestamp; sqlCommand.Parameters.AddWithValue("p_date_end", businessObject.Date_end); sqlCommand.Parameters["p_date_end"].NpgsqlDbType = NpgsqlDbType.Timestamp; MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.Idset_methods_calib = Convert.ToInt32(sqlCommand.Parameters["p_idset_methods_calib"].Value); return(true); } catch (Exception ex) { throw new Exception("CSet_methods_calib::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CSet_methods_calib</returns> internal List <CSet_methods_calib> PopulateObjectsFromReader(IDataReader dataReader) { List <CSet_methods_calib> list = new List <CSet_methods_calib>(); while (dataReader.Read()) { CSet_methods_calib businessObject = new CSet_methods_calib(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CSet_methods_calib business object</returns> public CSet_methods_calib SelectByPrimaryKey(CSet_methods_calibKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_set_methods_calib_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_idset_methods_calib", NpgsqlDbType.Integer, 4, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idset_methods_calib)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CSet_methods_calib businessObject = new CSet_methods_calib(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CSet_methods_calib::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Este método obtiene las calibraciones de los métodos /// </summary> /// <param name="idelement"></param> /// <param name="idmr_detail"></param> /// <param name="idreactive_medium"></param> /// <param name="idreactive_modif"></param> /// <returns></returns> public CSet_methods_calib GetMethodCalib(int idelement, short idmr_detail, int?idreactive_medium, int?idreactive_modif) { CSet_methods_calibFactory faSet_methods_calib = new CSet_methods_calibFactory(); List <CSet_methods_calib> lstSet_methods_calib = faSet_methods_calib.GetAll() .Where(c => c.Idelement == idelement && c.Idmr_detail == idmr_detail && (idreactive_medium == null || c.Idreactive_medium == idreactive_medium) && (idreactive_modif == null || c.Idreactive_modif == idreactive_modif)).ToList(); if (lstSet_methods_calib.Count > 0) { return(lstSet_methods_calib.First()); } CSet_methods_calib oSet_methods_calib = new CSet_methods_calib(); oSet_methods_calib.Idelement = idelement; oSet_methods_calib.Idmr_detail = idmr_detail; oSet_methods_calib.Idreactive_medium = idreactive_medium; oSet_methods_calib.Idreactive_modif = idreactive_modif; return(oSet_methods_calib); }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CSet_methods_calib businessObject, IDataReader dataReader) { businessObject.Idset_methods_calib = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idset_methods_calib.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idsolution_pattern.ToString()))) { businessObject.Idsolution_pattern = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idsolution_pattern.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idelement.ToString()))) { businessObject.Idelement = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idelement.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idmr_detail.ToString()))) { businessObject.Idmr_detail = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idmr_detail.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idreactive_medium.ToString()))) { businessObject.Idreactive_medium = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idreactive_medium.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idreactive_modif.ToString()))) { businessObject.Idreactive_modif = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Idreactive_modif.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Order_set.ToString()))) { businessObject.Order_set = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Order_set.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Name_methods_calib.ToString()))) { businessObject.Name_methods_calib = dataReader.GetString(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Name_methods_calib.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.User_calib.ToString()))) { businessObject.User_calib = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.User_calib.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Date_calib.ToString()))) { businessObject.Date_calib = dataReader.GetDateTime(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Date_calib.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Status_set.ToString()))) { businessObject.Status_set = dataReader.GetInt32(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Status_set.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Date_ini.ToString()))) { businessObject.Date_ini = dataReader.GetDateTime(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Date_ini.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Date_end.ToString()))) { businessObject.Date_end = dataReader.GetDateTime(dataReader.GetOrdinal(CSet_methods_calib.CSet_methods_calibFields.Date_end.ToString())); } }