示例#1
0
        ///<Summary>
        ///Select all rows
        ///This method returns all data rows in the table products
        ///</Summary>
        ///<returns>
        ///List-IDAOProducts.
        ///</returns>
        ///<parameters>
        ///
        ///</parameters>
        public static List <IDAOProducts> SelectAll()
        {
            Doing(null);
            MySqlCommand command = new MySqlCommand();

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

            command.Connection = staticConnection;

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

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


                List <IDAOProducts> objList = new List <IDAOProducts>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOProducts retObj = new DAOProducts();
                        retObj._supplierIds            = Convert.IsDBNull(row["supplier_ids"]) ? null : (string)row["supplier_ids"];
                        retObj._id                     = Convert.IsDBNull(row["id"]) ? null : (string)row["id"];
                        retObj._productCode            = Convert.IsDBNull(row["product_code"]) ? null : (string)row["product_code"];
                        retObj._productName            = Convert.IsDBNull(row["product_name"]) ? null : (string)row["product_name"];
                        retObj._description            = Convert.IsDBNull(row["description"]) ? null : (string)row["description"];
                        retObj._standardCost           = Convert.IsDBNull(row["standard_cost"]) ? null : (string)row["standard_cost"];
                        retObj._listPrice              = Convert.IsDBNull(row["list_price"]) ? null : (string)row["list_price"];
                        retObj._reorderLevel           = Convert.IsDBNull(row["reorder_level"]) ? null : (string)row["reorder_level"];
                        retObj._targetLevel            = Convert.IsDBNull(row["target_level"]) ? null : (string)row["target_level"];
                        retObj._quantityPerUnit        = Convert.IsDBNull(row["quantity_per_unit"]) ? null : (string)row["quantity_per_unit"];
                        retObj._discontinued           = Convert.IsDBNull(row["discontinued"]) ? null : (string)row["discontinued"];
                        retObj._minimumReorderQuantity = Convert.IsDBNull(row["minimum_reorder_quantity"]) ? null : (string)row["minimum_reorder_quantity"];
                        retObj._category               = Convert.IsDBNull(row["category"]) ? null : (string)row["category"];
                        retObj._attachments            = Convert.IsDBNull(row["attachments"]) ? null : (byte[])row["attachments"];
                        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();
            }
        }
示例#2
0
        ///<Summary>
        ///Select one row by primary key(s)
        ///This method returns one row from the table products based on the primary key(s)
        ///</Summary>
        ///<returns>
        ///IDAOProducts
        ///</returns>
        ///<parameters>
        ///string id
        ///</parameters>
        public static IDAOProducts SelectOne(string id)
        {
            Doing(null);
            MySqlCommand command = new MySqlCommand();

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

            command.Connection = staticConnection;

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

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

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


                DAOProducts retObj = null;
                if (dt.Rows.Count > 0)
                {
                    retObj = new DAOProducts();
                    retObj._supplierIds            = Convert.IsDBNull(dt.Rows[0]["supplier_ids"]) ? null : (string)dt.Rows[0]["supplier_ids"];
                    retObj._id                     = Convert.IsDBNull(dt.Rows[0]["id"]) ? null : (string)dt.Rows[0]["id"];
                    retObj._productCode            = Convert.IsDBNull(dt.Rows[0]["product_code"]) ? null : (string)dt.Rows[0]["product_code"];
                    retObj._productName            = Convert.IsDBNull(dt.Rows[0]["product_name"]) ? null : (string)dt.Rows[0]["product_name"];
                    retObj._description            = Convert.IsDBNull(dt.Rows[0]["description"]) ? null : (string)dt.Rows[0]["description"];
                    retObj._standardCost           = Convert.IsDBNull(dt.Rows[0]["standard_cost"]) ? null : (string)dt.Rows[0]["standard_cost"];
                    retObj._listPrice              = Convert.IsDBNull(dt.Rows[0]["list_price"]) ? null : (string)dt.Rows[0]["list_price"];
                    retObj._reorderLevel           = Convert.IsDBNull(dt.Rows[0]["reorder_level"]) ? null : (string)dt.Rows[0]["reorder_level"];
                    retObj._targetLevel            = Convert.IsDBNull(dt.Rows[0]["target_level"]) ? null : (string)dt.Rows[0]["target_level"];
                    retObj._quantityPerUnit        = Convert.IsDBNull(dt.Rows[0]["quantity_per_unit"]) ? null : (string)dt.Rows[0]["quantity_per_unit"];
                    retObj._discontinued           = Convert.IsDBNull(dt.Rows[0]["discontinued"]) ? null : (string)dt.Rows[0]["discontinued"];
                    retObj._minimumReorderQuantity = Convert.IsDBNull(dt.Rows[0]["minimum_reorder_quantity"]) ? null : (string)dt.Rows[0]["minimum_reorder_quantity"];
                    retObj._category               = Convert.IsDBNull(dt.Rows[0]["category"]) ? null : (string)dt.Rows[0]["category"];
                    retObj._attachments            = Convert.IsDBNull(dt.Rows[0]["attachments"]) ? null : (byte[])dt.Rows[0]["attachments"];
                    retObj._ctrVersion             = Convert.IsDBNull(dt.Rows[0]["ctr_version"]) ? null : (string)dt.Rows[0]["ctr_version"];
                }
                return(retObj);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
示例#3
0
        ///<Summary>
        ///Select all rows by filter criteria
        ///This method returns all data rows in the table using criteriaquery api products
        ///</Summary>
        ///<returns>
        ///List-IDAOProducts.
        ///</returns>
        ///<parameters>
        ///IList<IDataCriterion> listCriterion, IList<IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake
        ///</parameters>
        public static List <IDAOProducts> SelectAllByCriteria(IList <IDataCriterion> listCriterion, IList <IDataOrderBy> listOrder, IDataSkip dataSkip, IDataTake dataTake)
        {
            Doing(null);
            MySqlCommand command = new MySqlCommand();

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

            command.Connection = staticConnection;

            DataTable        dt         = new DataTable("products");
            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 <IDAOProducts> objList = new List <IDAOProducts>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOProducts retObj = new DAOProducts();
                        retObj._supplierIds            = Convert.IsDBNull(row["supplier_ids"]) ? null : (string)row["supplier_ids"];
                        retObj._id                     = Convert.IsDBNull(row["id"]) ? null : row["id"].ToString();
                        retObj._productCode            = Convert.IsDBNull(row["product_code"]) ? null : (string)row["product_code"];
                        retObj._productName            = Convert.IsDBNull(row["product_name"]) ? null : (string)row["product_name"];
                        retObj._description            = Convert.IsDBNull(row["description"]) ? null : (string)row["description"];
                        retObj._standardCost           = Convert.IsDBNull(row["standard_cost"]) ? null : row["standard_cost"].ToString();
                        retObj._listPrice              = Convert.IsDBNull(row["list_price"]) ? null : row["list_price"].ToString();
                        retObj._reorderLevel           = Convert.IsDBNull(row["reorder_level"]) ? null : (string)row["reorder_level"].ToString();
                        retObj._targetLevel            = Convert.IsDBNull(row["target_level"]) ? null : (string)row["target_level"].ToString();
                        retObj._quantityPerUnit        = Convert.IsDBNull(row["quantity_per_unit"]) ? null : (string)row["quantity_per_unit"].ToString();
                        retObj._discontinued           = Convert.IsDBNull(row["discontinued"]) ? null : (string)row["discontinued"].ToString();
                        retObj._minimumReorderQuantity = Convert.IsDBNull(row["minimum_reorder_quantity"]) ? null : (string)row["minimum_reorder_quantity"].ToString();
                        retObj._category               = Convert.IsDBNull(row["category"]) ? null : (string)row["category"].ToString();
                        retObj._attachments            = Convert.IsDBNull(row["attachments"]) ? null : (byte[])row["attachments"];
                        retObj._ctrVersion             = Convert.IsDBNull(row["ctr_version"]) ? null : (string)row["ctr_version"].ToString();
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch (Exception ex)
            {
                Failed(null, ex);
                Handle(null, ex);
                return(null);
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }