Example #1
0
        ///<Summary>
        ///Select all rows by filter criteria
        ///This method returns all data rows in the table using criteriaquery api Shippers
        ///</Summary>
        ///<returns>
        ///IList-IDAOShippers.
        ///</returns>
        ///<parameters>
        ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake
        ///</parameters>
        public static IList <IDAOShippers> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake)
        {
            Doing(null);
            SqlCommand command = new SqlCommand();

            command.CommandText = GetSelectionCriteria(InlineProcs.ctprShippers_SelectAllByCriteria, null, listCriterion, listOrder, dataSkip, dataTake);
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

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

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

                List <IDAOShippers> objList = new List <IDAOShippers>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOShippers retObj = new DAOShippers();
                        retObj._shipperID   = Convert.IsDBNull(row["ShipperID"]) ? (Int32?)null : (Int32?)row["ShipperID"];
                        retObj._companyName = Convert.IsDBNull(row["CompanyName"]) ? null : (string)row["CompanyName"];
                        retObj._phone       = Convert.IsDBNull(row["Phone"]) ? null : (string)row["Phone"];
                        retObj._ctrVersion  = Convert.IsDBNull(row["ctr_version"]) ? (Int32?)null : (Int32?)row["ctr_version"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Example #2
0
        ///<Summary>
        ///Select one row by primary key(s)
        ///This method returns one row from the table Shippers based on the primary key(s)
        ///</Summary>
        ///<returns>
        ///IDAOShippers
        ///</returns>
        ///<parameters>
        ///Int32? shipperID
        ///</parameters>
        public static IDAOShippers SelectOne(Int32?shipperID)
        {
            Doing(null);
            SqlCommand command = new SqlCommand();

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

            command.Connection = staticConnection;

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

            try
            {
                command.Parameters.Add(CtSqlParameter.Get("@ShipperID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, (object)shipperID ?? (object)DBNull.Value));

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

                DAOShippers retObj = null;
                if (dt.Rows.Count > 0)
                {
                    retObj              = new DAOShippers();
                    retObj._shipperID   = Convert.IsDBNull(dt.Rows[0]["ShipperID"]) ? (Int32?)null : (Int32?)dt.Rows[0]["ShipperID"];
                    retObj._companyName = Convert.IsDBNull(dt.Rows[0]["CompanyName"]) ? null : (string)dt.Rows[0]["CompanyName"];
                    retObj._phone       = Convert.IsDBNull(dt.Rows[0]["Phone"]) ? null : (string)dt.Rows[0]["Phone"];
                    retObj._ctrVersion  = Convert.IsDBNull(dt.Rows[0]["ctr_version"]) ? (Int32?)null : (Int32?)dt.Rows[0]["ctr_version"];
                }
                return(retObj);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }