Ejemplo n.º 1
0
        ///<Summary>
        ///</Summary>
        ///<returns>
        ///Int32
        ///</returns>
        ///<parameters>
        ///DAOStaff daoStaff
        ///</parameters>
        public static Int32 SelectAllBySearchFieldsCount(DAOStaff daoStaff)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprstaff_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)daoStaff.Id ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoStaff.Name ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@designationid", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, (object)daoStaff.Designationid ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@departmentid", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoStaff.Departmentid ?? (object)DBNull.Value));

                staticConnection.Open();
                Int32 retCount = (Int32)command.ExecuteScalar();

                return(retCount);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Ejemplo n.º 2
0
        ///<Summary>
        ///</Summary>
        ///<returns>
        ///IList-DAOStaff.
        ///</returns>
        ///<parameters>
        ///DAOStaff daoStaff
        ///</parameters>
        public static IList <DAOStaff> SelectAllBySearchFields(DAOStaff daoStaff)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprstaff_SelectAllBySearchFields;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("staff");
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(command);

            try
            {
                command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoStaff.Id ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)daoStaff.Name ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@designationid", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, (object)daoStaff.Designationid ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@departmentid", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)daoStaff.Departmentid ?? (object)DBNull.Value));

                staticConnection.Open();
                sqlAdapter.Fill(dt);

                List <DAOStaff> objList = new List <DAOStaff>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOStaff retObj = new DAOStaff();
                        retObj._id            = Convert.IsDBNull(row["id"]) ? (Int32?)null : (Int32?)row["id"];
                        retObj._name          = Convert.IsDBNull(row["name"]) ? null : (string)row["name"];
                        retObj._designationid = Convert.IsDBNull(row["designationid"]) ? (Int32?)null : (Int32?)row["designationid"];
                        retObj._departmentid  = Convert.IsDBNull(row["departmentid"]) ? (Int32?)null : (Int32?)row["departmentid"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Ejemplo n.º 3
0
        ///<Summary>
        ///Select all rows
        ///This method returns all data rows in the table staff
        ///</Summary>
        ///<returns>
        ///IList-DAOStaff.
        ///</returns>
        ///<parameters>
        ///
        ///</parameters>
        public static IList <DAOStaff> SelectAll()
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprstaff_SelectAll;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("staff");
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(command);

            try
            {
                staticConnection.Open();
                sqlAdapter.Fill(dt);

                List <DAOStaff> objList = new List <DAOStaff>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOStaff retObj = new DAOStaff();
                        retObj._id            = Convert.IsDBNull(row["id"]) ? (Int32?)null : (Int32?)row["id"];
                        retObj._name          = Convert.IsDBNull(row["name"]) ? null : (string)row["name"];
                        retObj._designationid = Convert.IsDBNull(row["designationid"]) ? (Int32?)null : (Int32?)row["designationid"];
                        retObj._departmentid  = Convert.IsDBNull(row["departmentid"]) ? (Int32?)null : (Int32?)row["departmentid"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Ejemplo n.º 4
0
        ///<Summary>
        ///Select one row by primary key(s)
        ///This method returns one row from the table staff based on the primary key(s)
        ///</Summary>
        ///<returns>
        ///DAOStaff
        ///</returns>
        ///<parameters>
        ///Int32? id
        ///</parameters>
        public static DAOStaff SelectOne(Int32?id)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprstaff_SelectOne;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("staff");
            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);

                DAOStaff retObj = null;
                if (dt.Rows.Count > 0)
                {
                    retObj                = new DAOStaff();
                    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._designationid = Convert.IsDBNull(dt.Rows[0]["designationid"]) ? (Int32?)null : (Int32?)dt.Rows[0]["designationid"];
                    retObj._departmentid  = Convert.IsDBNull(dt.Rows[0]["departmentid"]) ? (Int32?)null : (Int32?)dt.Rows[0]["departmentid"];
                }
                return(retObj);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }