///<Summary>
        ///Select all rows by foreign key
        ///This method returns all data rows in the table purchase_order_details based on a foreign key
        ///</Summary>
        ///<returns>
        ///List-IDAOPurchaseOrderDetails.
        ///</returns>
        ///<parameters>
        ///string inventoryId
        ///</parameters>
        public static List <IDAOPurchaseOrderDetails> SelectAllByInventoryId(string inventoryId)
        {
            Doing(null);
            MySqlCommand command = new MySqlCommand();

            command.CommandText = "ctpr_purchase_order_details_getbyinventoryid";
            command.CommandType = CommandType.StoredProcedure;
            MySqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable        dt         = new DataTable("purchase_order_details");
            MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(command);

            try
            {
                command.Parameters.Add(new MySqlParameter("?P_INVENTORY_ID", MySqlDbType.VarChar, 0, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, (object)inventoryId ?? (object)DBNull.Value));

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


                List <IDAOPurchaseOrderDetails> objList = new List <IDAOPurchaseOrderDetails>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOPurchaseOrderDetails retObj = new DAOPurchaseOrderDetails();
                        retObj._id = Convert.IsDBNull(row["id"]) ? null : (string)row["id"];
                        retObj._purchaseOrderId   = Convert.IsDBNull(row["purchase_order_id"]) ? null : (string)row["purchase_order_id"];
                        retObj._productId         = Convert.IsDBNull(row["product_id"]) ? null : (string)row["product_id"];
                        retObj._quantity          = Convert.IsDBNull(row["quantity"]) ? null : (string)row["quantity"];
                        retObj._unitCost          = Convert.IsDBNull(row["unit_cost"]) ? null : (string)row["unit_cost"];
                        retObj._dateReceived      = Convert.IsDBNull(row["date_received"]) ? null : (string)row["date_received"];
                        retObj._postedToInventory = Convert.IsDBNull(row["posted_to_inventory"]) ? null : (string)row["posted_to_inventory"];
                        retObj._inventoryId       = Convert.IsDBNull(row["inventory_id"]) ? null : (string)row["inventory_id"];
                        retObj._ctrVersion        = Convert.IsDBNull(row["ctr_version"]) ? null : (string)row["ctr_version"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
        ///<Summary>
        ///Select all rows by filter criteria
        ///This method returns all data rows in the table using criteriaquery api purchase_order_details
        ///</Summary>
        ///<returns>
        ///List-IDAOPurchaseOrderDetails.
        ///</returns>
        ///<parameters>
        ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake
        ///</parameters>
        public static List <IDAOPurchaseOrderDetails> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake)
        {
            Doing(null);
            MySqlCommand command = new MySqlCommand();

            command.CommandText = "ctpr_purchase_order_details_getbycriteria";
            command.CommandType = CommandType.StoredProcedure;
            MySqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable        dt         = new DataTable("purchase_order_details");
            MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(command);

            try
            {
                string whereClause = GetSelectionCriteria(listCriterion);
                string orderClause = GetSelectionOrder(listOrder);
                string skipClause  = GetSelectionSkip(dataSkip);
                string takeClause  = GetSelectionTake(dataTake);
                command.Parameters.Add(new MySqlParameter("?P_SKIPCLAUSE", MySqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)skipClause ?? (object)DBNull.Value));
                command.Parameters.Add(new MySqlParameter("?P_TAKECLAUSE", MySqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)takeClause ?? (object)DBNull.Value));
                command.Parameters.Add(new MySqlParameter("?P_WHERECLAUSE", MySqlDbType.VarChar, 500, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)whereClause ?? (object)DBNull.Value));
                command.Parameters.Add(new MySqlParameter("?P_ORDERCLAUSE", MySqlDbType.VarChar, 500, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)orderClause ?? (object)DBNull.Value));
                command.Parameters.Add(new MySqlParameter("?P_SKIPCLAUSE", MySqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)skipClause ?? (object)DBNull.Value));
                command.Parameters.Add(new MySqlParameter("?P_TAKECLAUSE", MySqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (object)takeClause ?? (object)DBNull.Value));

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


                List <IDAOPurchaseOrderDetails> objList = new List <IDAOPurchaseOrderDetails>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOPurchaseOrderDetails retObj = new DAOPurchaseOrderDetails();
                        retObj._id = Convert.IsDBNull(row["id"]) ? null : (string)row["id"];
                        retObj._purchaseOrderId   = Convert.IsDBNull(row["purchase_order_id"]) ? null : (string)row["purchase_order_id"];
                        retObj._productId         = Convert.IsDBNull(row["product_id"]) ? null : (string)row["product_id"];
                        retObj._quantity          = Convert.IsDBNull(row["quantity"]) ? null : (string)row["quantity"];
                        retObj._unitCost          = Convert.IsDBNull(row["unit_cost"]) ? null : (string)row["unit_cost"];
                        retObj._dateReceived      = Convert.IsDBNull(row["date_received"]) ? null : (string)row["date_received"];
                        retObj._postedToInventory = Convert.IsDBNull(row["posted_to_inventory"]) ? null : (string)row["posted_to_inventory"];
                        retObj._inventoryId       = Convert.IsDBNull(row["inventory_id"]) ? null : (string)row["inventory_id"];
                        retObj._ctrVersion        = Convert.IsDBNull(row["ctr_version"]) ? null : (string)row["ctr_version"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }