//------------------------------------------------------------------------------------------------------
        #endregion
        
        #region /*--------- Updat ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the object properties to SQL paramters and executes the update procedure.
        /// </summary>
        /// <param name="ItemsOrdersDetailsObj">Model object.</param>
        /// <returns>The result of update query.</returns>
        //--------------------------------------------------------------------
        public bool Updat(ItemsOrdersDetailsModel ItemsOrdersDetailsObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[ItemsOrdersDetails_Update]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
                myCommand.Parameters.Add("@ItemID", SqlDbType.Int, 4).Value = ItemsOrdersDetailsObj.ItemID;
				myCommand.Parameters.Add("@Title", SqlDbType.NVarChar, 128).Value = ItemsOrdersDetailsObj.Title;
				myCommand.Parameters.Add("@Price", SqlDbType.NVarChar, 128).Value = ItemsOrdersDetailsObj.Price;
				myCommand.Parameters.Add("@Quantity", SqlDbType.Int, 4).Value = ItemsOrdersDetailsObj.Quantity;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- PopulateModelFromIDataReader ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Populates model from IDataReader .
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        private ItemsOrdersDetailsModel PopulateModelFromIDataReader(IDataReader reader)
        {
            //Create a new object
            ItemsOrdersDetailsModel ItemsOrdersDetailsObj = new ItemsOrdersDetailsModel();
            //Fill the object with data
            //------------------------------------------------
            //ItemID
            //------------------------------------------------
            if (reader["ItemID"] != DBNull.Value)
                ItemsOrdersDetailsObj.ItemID = (int)reader["ItemID"];
            //------------------------------------------------

			//------------------------------------------------
			//[Title]
			//------------------------------------------------
			if (reader["Title"] != DBNull.Value)
			    ItemsOrdersDetailsObj.Title = (string)reader["Title"];
			//------------------------------------------------
			//------------------------------------------------
			//[Price]
			//------------------------------------------------
			if (reader["Price"] != DBNull.Value)
			    ItemsOrdersDetailsObj.Price = (string)reader["Price"];
			//------------------------------------------------
			//------------------------------------------------
			//[Quantity]
			//------------------------------------------------
			if (reader["Quantity"] != DBNull.Value)
			    ItemsOrdersDetailsObj.Quantity = (int)reader["Quantity"];
            //------------------------------------------------
            //[CurrentPrice]
            //------------------------------------------------
            if (reader["CurrentPrice"] != DBNull.Value)
                ItemsOrdersDetailsObj.CurrentPrice = (string)reader["CurrentPrice"];
            //------------------------------------------------
            //[Barcode]
            //------------------------------------------------
            if (reader["Barcode"] != DBNull.Value)
                ItemsOrdersDetailsObj.Barcode = (string)reader["Barcode"];
            //------------------------------------------------
            //[ByUnit]
            //------------------------------------------------
            if (reader["ByUnit"] != DBNull.Value)
                ItemsOrdersDetailsObj.ByUnit = (string)reader["ByUnit"];
            //------------------------------------------------
            //[ByCarton]
            //------------------------------------------------
            if (reader["ByCarton"] != DBNull.Value)
                ItemsOrdersDetailsObj.ByCarton = (string)reader["ByCarton"];
            //------------------------------------------------
            //Return the populated object
            return ItemsOrdersDetailsObj;
        }
Exemple #3
0
        public static void AddToCart(int itemID, ref ItemsEntity item, ref ItemCategoriesEntity category)
        {
            Guid OwnerID = SitesHandler.GetOwnerIDAsGuid();
            //---------------------------------------------------------
            Languages langID = SiteSettings.GetCurrentLanguage();

            if (item == null)
            {
                item = ItemsFactory.GetObject(itemID, langID, UsersTypes.User, OwnerID);
            }
            if (category == null)
            {
                category = ItemCategoriesFactory.GetObject(item.CategoryID, langID, OwnerID);
            }

            if (item != null && category != null)
            {
                List <ItemsOrdersDetailsModel> CartList = GetCartList();
                //---------------------------------------------------------
                bool existIntoCart = false;
                foreach (ItemsOrdersDetailsModel p in CartList)
                {
                    if (p.ItemID == itemID)
                    {
                        p.Quantity   += 1;
                        existIntoCart = true;
                        break;
                    }
                }
                if (!existIntoCart)
                {
                    ItemsOrdersDetailsModel newP = new ItemsOrdersDetailsModel();
                    newP.ItemID   = itemID;
                    newP.Quantity = 1;
                    CartList.Add(newP);
                }
                //---------------------------------------------------------
                //Session["Cart"] = CartList;
            }
        }
Exemple #4
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------Updat--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates model object by calling sql data provider update method.
        /// </summary>
        /// <param name="ItemsOrdersDetailsObj">The model object.</param>
        /// <returns>The result of update operation.</returns>
        //--------------------------------------------------------------------
        public static bool Updat(ItemsOrdersDetailsModel ItemsOrdersDetailsObj)
        {
            return(ItemsOrdersDetailsSqlDataPrvider.Instance.Updat(ItemsOrdersDetailsObj));
        }