Example #1
0
        public List <ProductLevel> ListInv(CDBUtil dbUtil, MySqlConnection conn, bool isStockCountConfig)
        {
            string sql = "";

            sql = " SELECT * FROM ProductLevel WHERE Deleted = 0 ";
            MySqlDataReader reader;

            reader = dbUtil.sqlRetrive(sql, conn);
            List <ProductLevel> invList = new List <ProductLevel>();

            while (reader.Read())
            {
                ProductLevel invInfo = new ProductLevel();
                if (reader["ProductLevelID"] != DBNull.Value)
                {
                    invInfo.ProductLevelId = reader.GetInt32("ProductLevelID");
                }
                if (reader["ProductLevelCode"] != DBNull.Value)
                {
                    invInfo.ProductLevelCode = reader.GetString("ProductLevelCode");
                }
                if (reader["ProductLevelName"] != DBNull.Value)
                {
                    invInfo.ProductLevelName = reader.GetString("ProductLevelName");
                }
                invList.Add(invInfo);
            }
            reader.Close();
            return(invList);
        }
Example #2
0
        public ProductLevel GetProductLevel(MySqlConnection conn, int dbShopId)
        {
            ProductLevel productLevel = new ProductLevel();
            MySqlCommand cmd          = new MySqlCommand("select distinct inventoryid,inventoryname from inventoryview where inventoryid=" + dbShopId, conn);

            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                productLevel.ProductLevelId   = reader.GetInt32("InventoryID");
                productLevel.ProductLevelName = reader.GetString("InventoryName");
            }
            reader.Close();
            return(productLevel);
        }
Example #3
0
        public List <ProductLevel> ListInv(CDBUtil dbUtil, MySqlConnection conn, int staffRoleId)
        {
            bool   isHQ = false;
            string sql  = "";

            // Check shop is hq
            sql = " SELECT * FROM property WHERE HeadOrBranch=1";
            MySqlDataReader reader = dbUtil.sqlRetrive(sql, conn);

            if (reader.Read())
            {
                isHQ = true;
            }
            else
            {
                isHQ = false;
            }
            reader.Close();

            sql = "";
            if (isHQ)
            {
                sql = " SELECT * FROM ProductLevel WHERE Deleted = 0 AND IsInv=1 ";
            }
            else
            {
                sql = " SELECT * FROM ProductLevel WHERE Deleted = 0 AND IsInv=1 AND ProductLevelID <> 1  ";
            }

            System.Data.DataTable dtResult = dbUtil.List("SELECT * FROM staffroleviewinventory WHERE StaffRoleID=" + staffRoleId, conn);
            if (dtResult.Rows.Count > 0)
            {
                sql += " AND ProductLevelID IN ( ";
                for (int i = 0; i <= dtResult.Rows.Count - 1; i++)
                {
                    sql += dtResult.Rows[i]["ProductLevelID"].ToString();
                    if (i < dtResult.Rows.Count - 1)
                    {
                        sql += " , ";
                    }
                }
                sql += " ) ";
            }
            reader = dbUtil.sqlRetrive(sql, conn);
            List <ProductLevel> invList = new List <ProductLevel>();

            while (reader.Read())
            {
                ProductLevel invInfo = new ProductLevel();
                if (reader["ProductLevelID"] != DBNull.Value)
                {
                    invInfo.ProductLevelId = reader.GetInt32("ProductLevelID");
                }
                if (reader["ProductLevelCode"] != DBNull.Value)
                {
                    invInfo.ProductLevelCode = reader.GetString("ProductLevelCode");
                }
                if (reader["ProductLevelName"] != DBNull.Value)
                {
                    invInfo.ProductLevelName = reader.GetString("ProductLevelName");
                }
                invList.Add(invInfo);
            }
            reader.Close();
            return(invList);
        }