///<Summary> ///</Summary> ///<returns> ///Int32 ///</returns> ///<parameters> ///DAOVisitation daoVisitation ///</parameters> public static Int32 SelectAllBySearchFieldsCount(DAOVisitation daoVisitation) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprVisitation_SelectAllBySearchFieldsCount; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; try { command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Id ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Name ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Arrived", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Arrived ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Staffid", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Staffid ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Purpose", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Purpose ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Departed", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Departed ?? (object)DBNull.Value)); staticConnection.Open(); Int32 retCount = (Int32)command.ExecuteScalar(); return(retCount); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///</Summary> ///<returns> ///IList-DAOVisitation. ///</returns> ///<parameters> ///DAOVisitation daoVisitation ///</parameters> public static IList <DAOVisitation> SelectAllBySearchFields(DAOVisitation daoVisitation) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprVisitation_SelectAllBySearchFields; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Visitation"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Id ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Name ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Arrived", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Arrived ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Staffid", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Staffid ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Purpose", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Purpose ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Departed", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoVisitation.Departed ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); List <DAOVisitation> objList = new List <DAOVisitation>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAOVisitation retObj = new DAOVisitation(); retObj._id = Convert.IsDBNull(row["id"]) ? (Int32?)null : (Int32?)row["id"]; retObj._name = Convert.IsDBNull(row["Name"]) ? null : (string)row["Name"]; retObj._arrived = Convert.IsDBNull(row["Arrived"]) ? (DateTime?)null : (DateTime?)row["Arrived"]; retObj._staffid = Convert.IsDBNull(row["Staffid"]) ? (Int32?)null : (Int32?)row["Staffid"]; retObj._purpose = Convert.IsDBNull(row["Purpose"]) ? null : (string)row["Purpose"]; retObj._departed = Convert.IsDBNull(row["Departed"]) ? (DateTime?)null : (DateTime?)row["Departed"]; objList.Add(retObj); } } return(objList); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///Select all rows ///This method returns all data rows in the table Visitation ///</Summary> ///<returns> ///IList-DAOVisitation. ///</returns> ///<parameters> /// ///</parameters> public static IList <DAOVisitation> SelectAll() { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprVisitation_SelectAll; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Visitation"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { staticConnection.Open(); sqlAdapter.Fill(dt); List <DAOVisitation> objList = new List <DAOVisitation>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAOVisitation retObj = new DAOVisitation(); retObj._id = Convert.IsDBNull(row["id"]) ? (Int32?)null : (Int32?)row["id"]; retObj._name = Convert.IsDBNull(row["Name"]) ? null : (string)row["Name"]; retObj._arrived = Convert.IsDBNull(row["Arrived"]) ? (DateTime?)null : (DateTime?)row["Arrived"]; retObj._staffid = Convert.IsDBNull(row["Staffid"]) ? (Int32?)null : (Int32?)row["Staffid"]; retObj._purpose = Convert.IsDBNull(row["Purpose"]) ? null : (string)row["Purpose"]; retObj._departed = Convert.IsDBNull(row["Departed"]) ? (DateTime?)null : (DateTime?)row["Departed"]; objList.Add(retObj); } } return(objList); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///Select one row by primary key(s) ///This method returns one row from the table Visitation based on the primary key(s) ///</Summary> ///<returns> ///DAOVisitation ///</returns> ///<parameters> ///Int32? id ///</parameters> public static DAOVisitation SelectOne(Int32?id) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprVisitation_SelectOne; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("Visitation"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)id ?? (object)DBNull.Value)); staticConnection.Open(); sqlAdapter.Fill(dt); DAOVisitation retObj = null; if (dt.Rows.Count > 0) { retObj = new DAOVisitation(); retObj._id = Convert.IsDBNull(dt.Rows[0]["id"]) ? (Int32?)null : (Int32?)dt.Rows[0]["id"]; retObj._name = Convert.IsDBNull(dt.Rows[0]["Name"]) ? null : (string)dt.Rows[0]["Name"]; retObj._arrived = Convert.IsDBNull(dt.Rows[0]["Arrived"]) ? (DateTime?)null : (DateTime?)dt.Rows[0]["Arrived"]; retObj._staffid = Convert.IsDBNull(dt.Rows[0]["Staffid"]) ? (Int32?)null : (Int32?)dt.Rows[0]["Staffid"]; retObj._purpose = Convert.IsDBNull(dt.Rows[0]["Purpose"]) ? null : (string)dt.Rows[0]["Purpose"]; retObj._departed = Convert.IsDBNull(dt.Rows[0]["Departed"]) ? (DateTime?)null : (DateTime?)dt.Rows[0]["Departed"]; } return(retObj); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }