Exemplo n.º 1
0
        public int DeleteDataBL(StoreInventoryBL oStoreInventoryBL)
        {
            StoreDataAccessLayer oStoreDataAccessLayer = new StoreDataAccessLayer();
            StoreInventoryDL     oStoreInventoryDL     = new StoreInventoryDL();

            oStoreInventoryDL.Id = oStoreInventoryBL.Id;

            int rowCount = oStoreDataAccessLayer.DeleteDataDL(oStoreInventoryDL);

            return(rowCount);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to Insert Data
        /// </summary>
        /// <param name="oStoreInventoryBL"></param>
        /// <returns></returns>

        public int InsertDataDL(StoreInventoryBL oStoreInventoryBL)
        {
            StoreDataAccessLayer oStoreDataAccessLayer = new StoreDataAccessLayer();
            StoreInventoryDL     oStoreInventoryDL     = new StoreInventoryDL();

            oStoreInventoryDL.ContentName     = oStoreInventoryBL.ContentName;
            oStoreInventoryDL.ContentQuantity = oStoreInventoryBL.ContentQuantity;

            int rowCount = oStoreDataAccessLayer.InsertDataDL(oStoreInventoryDL);

            return(rowCount);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to Delete Data
        /// </summary>
        /// <param name="oStoreInventoryDL"></param>
        /// <returns></returns>
        public int DeleteDataDL(StoreInventoryDL oStoreInventoryDL)
        {
            if (ConnectionState.Closed == oConnection.oSqlConnection.State)
            {
                oConnection.oSqlConnection.Open();
            }

            oSqlCommand.CommandText = "DELETE FROM dbo.StoreInventory WHERE ID = @ContentID";
            oSqlCommand.Parameters.AddWithValue("@ContentID", oStoreInventoryDL.Id);

            //Open Connection
            oSqlCommand.Connection = oConnection.oSqlConnection;

            //execute command
            int rowCount = oSqlCommand.ExecuteNonQuery();

            return(rowCount);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Metod to Insert Data
        /// </summary>
        /// <param name="oStoreInventoryDL"></param>
        /// <returns></returns>
        public int InsertDataDL(StoreInventoryDL oStoreInventoryDL)
        {
            if (ConnectionState.Closed == oConnection.oSqlConnection.State)
            {
                oConnection.oSqlConnection.Open();
            }

            oSqlCommand.CommandText = "INSERT INTO dbo.StoreInventory(ContentName, ContentQuantity) VALUES (@ContentName, @ContentQuantity)";
            oSqlCommand.Parameters.AddWithValue("@ContentName", oStoreInventoryDL.ContentName);
            oSqlCommand.Parameters.AddWithValue("@ContentQuantity", oStoreInventoryDL.ContentQuantity);

            //Open Connection
            oSqlCommand.Connection = oConnection.oSqlConnection;

            //execute command
            int rowCount = oSqlCommand.ExecuteNonQuery();

            return(rowCount);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Metho to Update Data
        /// </summary>
        /// <param name="oStoreInventoryDL"></param>
        /// <returns></returns>
        public int UpdateDataDL(StoreInventoryDL oStoreInventoryDL)
        {
            if (ConnectionState.Closed == oConnection.oSqlConnection.State)
            {
                oConnection.oSqlConnection.Open();
            }

            oSqlCommand.CommandText = "UPDATE dbo.StoreInventory SET ContentName = @ContentName, ContentQuantity = @ContentQuantity WHERE ID = @ContentID";
            oSqlCommand.Parameters.AddWithValue("@ContentName", oStoreInventoryDL.ContentName);
            oSqlCommand.Parameters.AddWithValue("@ContentQuantity", oStoreInventoryDL.ContentQuantity);
            oSqlCommand.Parameters.AddWithValue("@ContentID", oStoreInventoryDL.Id);

            //Open Connection
            oSqlCommand.Connection = oConnection.oSqlConnection;

            //execute command
            int rowCount = oSqlCommand.ExecuteNonQuery();

            return(rowCount);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method to read data
        /// </summary>
        /// <returns></returns>
        public IList <StoreInventoryDL> ReadDataDL()
        {
            //List collection to store data models
            IList <StoreInventoryDL> iStoreInventoryDL = new List <StoreInventoryDL>();

            //Object to data models
            StoreInventoryDL oStoreInventoryDL = null;

            if (ConnectionState.Closed == oConnection.oSqlConnection.State)
            {
                oConnection.oSqlConnection.Open();
            }

            oSqlCommand.CommandText = "SELECT * FROM dbo.StoreInventory";
            oSqlCommand.Connection  = oConnection.oSqlConnection;

            try
            {
                SqlDataReader oSqlDataReader = oSqlCommand.ExecuteReader();
                while (oSqlDataReader.Read())
                {
                    oStoreInventoryDL                 = new StoreInventoryDL();
                    oStoreInventoryDL.Id              = Convert.ToInt32(oSqlDataReader["Id"]);
                    oStoreInventoryDL.ContentName     = oSqlDataReader["ContentName"].ToString();
                    oStoreInventoryDL.ContentQuantity = Convert.ToInt32(oSqlDataReader["ContentQuantity"]);

                    iStoreInventoryDL.Add(oStoreInventoryDL);
                }
            }
            catch
            {
                throw;
            }

            //return oStoreInventory;
            return(iStoreInventoryDL);
        }