static void AddProducts(List <JToken> products) { if (displayed == false) { foreach (JToken p in products) { if (p.ToArray().Length > 2) { pc.Add(new Product { Name = p["name"].ToString(), Price = decimal.Parse(p["price"].ToString()), Collection = (p["collection"].ToString() == "" ? "" : p["collection"].ToString()) }); } else { pc.Add(new Product { Name = p["name"].ToString(), Price = decimal.Parse(p["price"].ToString()) }); } } displayed = true; } }
public static ProductCollection LoadAll(string sortExpression) { ProductCollection col1 = new ProductCollection(); col1.Add(new Product(1)); col1.Add(new Product(2)); col1.Add(new Product(3)); col1.Add(new Product(4)); col1.Sort(new GenericComparer <Product>(sortExpression, GenericComparer <Product> .SortOrder.Ascending)); return(col1); }
public void RunCreateView() { string name = null; string description = null; decimal price = 0; Console.Clear(); Console.WriteLine(ProductCommonOutputText.GetApplicationHeading()); Console.WriteLine(); Console.WriteLine(ProductCommonOutputText.GetColumnHeadings()); Console.WriteLine(); Console.Write("Enter product name:\t"); name = Console.ReadLine(); Console.Write("Enter product description:\t"); description = Console.ReadLine(); Console.Write("Enter price:\t"); price = decimal.Parse(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Pls press [S] to save product to database"); ConsoleKey consoleKey = Console.ReadKey().Key; if (consoleKey == ConsoleKey.S) { _products.Add(ProductObjectFactory.CreateNewProduct(name, description, price)); } }
public ProductCollection GetAllProductsCollection() { IDBManager dbm = new DBManager(); IDataReader reader = null; ProductCollection cols = new ProductCollection(); try { reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductsAll"); while (reader.Read()) { Product product = new Product(); product = ReaderToProduct(reader, product); cols.Add(product); } } catch (Exception ex) { log.Write(ex.Message, "GetAllProductsCollection"); throw (ex); } finally { if (reader != null) { reader.Close(); } dbm.Dispose(); } return(cols); }
internal static void ProductProc(IDataReader dr, FieldDictionary Fields, object Param) { ProductCollection coll = Param as ProductCollection; Product item = Mapper.ReadProduct(dr, Fields); coll.Add(item); }
public static ProductCollection GetVirtualKits(int pubid)//***EAC this is obsolete { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("sp_NCIPL_GetVirtualKits"); db.AddInParameter(dbCommand, "pubid", DbType.Int32, pubid); using (IDataReader dr = db.ExecuteReader(dbCommand)) { // Processing code ProductCollection collProducts = new ProductCollection(); while (dr.Read()) { Product k = new Product( dr.GetInt32(dr.GetOrdinal("pubid")), dr["productid"].ToString(), dr["longtitle"].ToString(), dr.GetInt32(dr.GetOrdinal("ncipl_qty")) ); collProducts.Add(k); } return(collProducts); } }
private void _productsGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { // track the user deletes an entity so later we can persist such deletion ProductEntity productToDelete = ((ProductEntity)e.Row.DataBoundItem); _productsToDelete.Add(productToDelete); }
/// <summary> /// Handles Search Products Enter key up event /// </summary> private async Task Products_EnterKeyUpAsync(string _searchTerm) { var product = await GetProductsAsync(productsSearchText); ProductCollection.Add(product); Quantity = 1; ProductsSearchText = ""; }
public static void Behavioral_IteratorDemo2() { var products = new ProductCollection(); products.Add(new Product(1, "a")); products.Add(new Product(2, "b")); products.Add(new Product(3, "c")); products.Add(new Product(4, "d")); var iterator = products.CreateIterator(); while (iterator.HasNext()) { Console.WriteLine(iterator.Current()); iterator.Next(); } }
/// <summary> /// Handles Products DropDownClosing event /// </summary> private async Task Products_DropDownClosingAsync() { var product = await GetProductsAsync(productsSearchText); ProductCollection.Add(product); Quantity = 1; ProductsSearchText = ""; }
/// <summary> /// Creates the product collection. /// </summary> /// <returns></returns> private static ProductCollection CreateProductCollection() { ProductCollection c = new ProductCollection(); for (int i = 0; i < 1000; i++) { c.Add(CreateProduct(i)); } Assert.AreEqual(1000, c.Count, "Before Save"); return(c); }
public static ProductCollection CreateProducts() { ProductCollection products = new ProductCollection(); products.Add(new Product { ProductId = 1, Quantity = 10, Sku = "ABC100", Description = "Nice Widget 1", Cost = 452.55m, IsTaxable = true }); products.Add(new Product { ProductId = 2, Quantity = 5, Sku = "ABC120", Description = "Nice Widget 2", Cost = 652.25m, IsTaxable = true }); products.Add(new Product { ProductId = 3, Quantity = 132, Sku = "BDC140", Description = "Nice Widget 3", Cost = 1256.00m, IsTaxable = true }); products.Add(new Product { ProductId = 4, Quantity = 62, Sku = "BDC180", Description = "Nice Widget 4", Cost = 874.25m, IsTaxable = true }); products.Add(new Product { ProductId = 5, Quantity = 1123, Sku = "FAC205", Description = "Nice Widget 5", Cost = 559.22m, IsTaxable = true }); products.Add(new Product { ProductId = 6, Quantity = 4, Sku = "GBS300", Description = "Nice Widget 6", Cost = 52.05m, IsTaxable = false }); return(products); }
private static void AddMethod(string input, ProductCollection colection) { int index = input.IndexOf(' '); string input2 = input.Substring(index + 1); string[] separatedByComma = input2.Split(';'); string name = separatedByComma[0]; decimal price = decimal.Parse(separatedByComma[1]); string producer = separatedByComma[2]; colection.Add(name, price, producer); Console.WriteLine("Product added"); }
protected ProductCollection VirtualizedCart(ProductCollection cart) { ProductCollection temp = new ProductCollection(); foreach (Product item in this.shoppingcart) { if (item.BookStatus == "V") { foreach (Product kit in NCIPLex.DAL2.DAL.GetVirtualKits(item.PubId)) { kit.NumQtyOrdered = kit.NumQtyOrdered * item.NumQtyOrdered; temp.Add(kit); } } else { temp.Add(item); } } return(temp); }
public static ProductCollection ToDtoCollection(this EntityCollection <ProductEntity> entities) { OnBeforeEntityCollectionToDtoCollection(entities); var seenObjects = new Hashtable(); var collection = new ProductCollection(); foreach (var entity in entities) { collection.Add(entity.ToDto(seenObjects, new Hashtable())); } OnAfterEntityCollectionToDtoCollection(entities, collection); return(collection); }
public static ProductCollection FindByName(string nameToMatch, int maximumRows, int startRowIndex, string sortExpression) { if (string.IsNullOrEmpty(nameToMatch)) { return(LoadForStore(maximumRows, startRowIndex, sortExpression)); } nameToMatch = StringHelper.FixSearchPattern(nameToMatch); //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + Product.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_Products"); selectQuery.Append(" WHERE StoreId = @storeId"); selectQuery.Append(" AND ProductId IN (SELECT DISTINCT ProductId FROM ac_ProductKitComponents)"); selectQuery.Append(" AND (Name LIKE @nameToMatch)"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId); database.AddInParameter(selectCommand, "@nameToMatch", System.Data.DbType.String, nameToMatch); //EXECUTE THE COMMAND ProductCollection results = new ProductCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { Product product = new Product(); Product.LoadDataReader(product, dr); results.Add(product); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
private static ProductCollection DBMapping(DBProductCollection dbCollection) { if (dbCollection == null) return null; ProductCollection collection = new ProductCollection(); foreach (DBProduct dbItem in dbCollection) { Product item = DBMapping(dbItem); collection.Add(item); } return collection; }
public ProductCollection GetDetailedProduct(int pid) { IPrefetchPath prefatchPath = new PrefetchPath(EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathComments).Filter.Add(CommentFields.Status == true); prefatchPath.Add(ProductEntity.PrefetchPathProductKeywords); prefatchPath.Add(ProductEntity.PrefetchPathProductSpecifications); prefatchPath.Add(ProductEntity.PrefetchPathProductPhotos); ProductEntity p = new ProductEntity(pid, prefatchPath); ProductCollection col = new ProductCollection(); col.Add(p); return(col); }
protected ProductCollection GetProducts() { ViewedItemsCollection collection = ViewedItemManager.GetCurrentViewedItem(pageSize, CurrentPageIndex, out totalItemCount); List <int> productsIDs = collection.Select(x => x.ProductVariantID).ToList(); ProductCollection productCollection = new ProductCollection(); foreach (var productID in productsIDs) { ProductVariant product = ProductManager.GetProductVariantByID(productID); productCollection.Add(product.Product); } return(productCollection); }
private static void ProductCollectionFunctionalities() { ProductCollection productCollection = new ProductCollection(); productCollection.Add( new Product { Category = Category.Beverages, Name = "Cola", Price = 12.5 }); productCollection.Add( new Product { Category = Category.Snacks, Name = "Chips", Price = 10.5 }); Console.WriteLine("\nExample using product Collection:\n"); Product beverageProduct = productCollection.FirstOrDefault(product => product.Category == Category.Beverages); Console.WriteLine($"Beverage:\t{beverageProduct?.ToString()}"); Product lastProduct = productCollection.GetItem(productCollection.Count - 1); Console.WriteLine($"Last product:\t{lastProduct}"); Console.WriteLine("\nProducts in productCollection:"); foreach (Product product in productCollection) { Console.WriteLine(product.ToString()); } }
static void Main(string[] args) { var browseHistory = new BrowseHistory <string>(); browseHistory.Push("a"); browseHistory.Push("b"); browseHistory.Push("c"); var browseHistoryIterator = browseHistory.CreateIterator(); while (browseHistoryIterator.HasNext()) { Console.WriteLine(browseHistoryIterator.Current()); browseHistoryIterator.Next(); } Console.WriteLine("--- Exercise ---"); var productCollection = new ProductCollection(); productCollection.Add(new Product(1, "Product 1")); productCollection.Add(new Product(2, "Product 2")); productCollection.Add(new Product(3, "Product 3")); var productIterator = productCollection.CreateIterator(); while (productIterator.HasNext()) { Console.WriteLine(productIterator.Current()); productIterator.Next(); } Console.ReadLine(); }
/// <summary> /// Loads a collection of Product objects from the database. /// </summary> /// <returns>A collection containing all of the Product objects in the database.</returns> public static ProductCollection LoadCollection(string spName, SqlParameter[] parms) { ProductCollection result = new ProductCollection(); using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms)) { while (reader.Read()) { Product tmp = new Product(); tmp.LoadFromReader(reader); result.Add(tmp); } } return(result); }
public async Task GetProductDetails() { _isProductLoaded = false; CheckLoadingStatus(); try { var assets = await Mvx.Resolve <IMobileDataService>().GetProducts(); if (assets == null) { return; } ProductCollection.Clear(); var head = new ProductItemViewModel() { IsHeading = true, Name = "Product Name", Price = "Price" }; ProductCollection.Add(head); foreach (var asset in assets) { var item = new ProductItemViewModel() { IsHeading = false, Id = asset.Id, Name = asset.Name, Description = asset.Description, Price = $"{asset.Price:C}", }; ProductCollection.Add(item); } RaisePropertyChanged(() => ProductCollection); HasFetched = true; } finally { _isProductLoaded = true; CheckLoadingStatus(); } }
private ProductCollection GetProducts() { int totalItems = 0; ProductCollection productCollection = new ProductCollection(); try { ViewedItemsCollection collection = ViewedItemManager.GetCurrentViewedItem(10, 0, out totalItems); List<int> productsIDs = collection.Select(x => x.ProductVariantID).ToList(); foreach (var productID in productsIDs) { ProductVariant product = ProductManager.GetProductVariantByID(productID); productCollection.Add(product.Product); } } catch { } return productCollection; }
public static ProductCollection Select(string WhereClause, string OrderByClause) { string Sql = string.Format("SELECT * from [product] WHERE ({0}) ORDER BY {1}", WhereClause, OrderByClause); //string ConnStr = @"Server=STUDENT05;Database=prs;Trusted_Connection=True;"; SqlCommand Cmd = CreateConnection(ConnStr, Sql, "Connection didn't open"); SqlDataReader Reader = Cmd.ExecuteReader(); if (!Reader.HasRows) { throw new ApplicationException("Result set has no rows!"); } ProductCollection products = new ProductCollection(); while (Reader.Read()) { int id = Reader.GetInt32(Reader.GetOrdinal("Id")); int vendorId = Reader.GetInt32(Reader.GetOrdinal("VendorId")); string name = Reader.GetString(Reader.GetOrdinal("Name")); string vendorPartNumber = Reader.GetString(Reader.GetOrdinal("VendorPartNumber")); decimal price = Reader.GetDecimal(Reader.GetOrdinal("Price")); string unit = Reader.GetString(Reader.GetOrdinal("Unit")); string photoPath = String.Empty; if (!Reader.IsDBNull(Reader.GetOrdinal("PhotoPath"))) { photoPath = Reader.GetString(Reader.GetOrdinal("PhotoPath")); } Vendor vendor = Vendor.Select(vendorId); Product product = new Product(); product.Id = id; product.Vendor = vendor; product.VendorId = vendor.Id; product.Name = name; product.VendorPartNumber = vendorPartNumber; product.Price = price; product.Unit = unit; product.PhotoPath = photoPath; products.Add(product); } Cmd.Connection.Close(); return(products); }
private ProductCollection GetProducts() { int totalItems = 0; ProductCollection productCollection = new ProductCollection(); try { ViewedItemsCollection collection = ViewedItemManager.GetCurrentViewedItem(10, 0, out totalItems); List <int> productsIDs = collection.Select(x => x.ProductVariantID).ToList(); foreach (var productID in productsIDs) { ProductVariant product = ProductManager.GetProductVariantByID(productID); productCollection.Add(product.Product); } } catch { } return(productCollection); }
public static ProductCollection Select(string WhereClause, string OrderByClause) { string Sql = string.Format("SELECT * from [Product] WHERE {0} ORDER BY {1}", WhereClause, OrderByClause); string ConnStr = @"Server=STUDENT05;Database=prs;Trusted_Connection=True;"; SqlConnection Conn = new SqlConnection(ConnStr); Conn.Open(); if (Conn.State != System.Data.ConnectionState.Open) { throw new ApplicationException("Connection didn't open"); } SqlCommand Cmd = new SqlCommand(Sql, Conn); SqlDataReader Reader = Cmd.ExecuteReader(); if (!Reader.HasRows) { throw new ApplicationException("Result set has no rows!"); } ProductCollection products = new ProductCollection(); while (Reader.Read()) { int id = Reader.GetInt32(Reader.GetOrdinal("Id")); string vendorid = Reader.GetString(Reader.GetOrdinal("VendorId")); string name = Reader.GetString(Reader.GetOrdinal("Name")); string vendorpartnumber = Reader.GetString(Reader.GetOrdinal("VendorPartNumber")); decimal price = Reader.GetDecimal(Reader.GetOrdinal("Price")); string unit = Reader.GetString(Reader.GetOrdinal("Unit")); string photopath = Reader.GetString(Reader.GetOrdinal("PhotoPath")); Product product = new Product(); product.Id = id; product.VendorId = vendorid; product.Name = name; product.VendorPartNumber = vendorpartnumber; product.Price = price; product.Unit = unit; product.PhotoPath = photopath; products.Add(product); } return(products); }
/// <summary> /// /// </summary> /// <returns></returns> public static ProductCollection GetCommend() { ProductCollection list = new ProductCollection(); string sql = "select * from t_product where iscommend = 1 order by prod_id desc limit 18"; MySqlDataReader reader = DbHelper.ExecuteDataReader(sql); if (reader.HasRows) { while (reader.Read()) { list.Add(FillDataRecord(reader)); } } reader.Close(); return list; }
public void Acc_ListSerialization() { ProductCollection products1 = FetchProductCollection(); using (Stream stream = new MemoryStream()) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, products1); stream.Position = 0; ProductCollection products2 = (ProductCollection)formatter.Deserialize(stream); stream.Close(); Assert.AreEqual(products1.Count, products2.Count); products2.ListChanged += products2_ListChanged; Product p = CreateProduct(1); products2.Add(p); Assert.AreEqual(Listchanged, true); } }
/// <summary> /// Gets a "recently viewed products" list /// </summary> /// <param name="Number">Number of products to load</param> /// <returns>"recently viewed products" list</returns> public static ProductCollection GetRecentlyViewedProducts(int Number) { ProductCollection products = new ProductCollection(); List<int> productIDs = GetRecentlyViewedProductsIDs(Number); foreach (int productID in productIDs) { Product product = GetProductByID(productID); if (product != null && product.Published && !product.Deleted) products.Add(product); } return products; }
public ProductCollection GetProductDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); IDataReader reader = null; ProductCollection cols = new ProductCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductsDynamic"); while (reader.Read()) { Product product = new Product(); product = ReaderToProduct(reader, product); cols.Add(product); /*product.ProductID = Int32.Parse(reader["ProductID"].ToString()); * product.Name = reader["Name"].ToString(); * product.Description = reader["Description"].ToString(); * product.ProductNumber = reader["ProductNumber"].ToString(); * product.MakeFlag = Boolean.Parse(reader["MakeFlag"].ToString()); * product.FinishedGoodsFlag = Boolean.Parse(reader["FinishedGoodsFlag"].ToString()); * product.Color = reader["Color"].ToString(); * product.SafetyStockLevel = Int16.Parse(reader["SafetyStockLevel"].ToString()); * product.ReorderPoint = Int16.Parse(reader["ReorderPoint"].ToString()); * product.StandardCost = Decimal.Parse(reader["StandardCost"].ToString()); * product.ListPrice =Decimal.Parse(reader["ListPrice"].ToString()); * product.Size = reader["Size"].ToString(); * product.SizeUnitMeasureCode = reader["SizeUnitMeasureCode"].ToString(); * product.WeightUnitMeasureCode = reader["WeightUnitMeasureCode"].ToString(); * product.Weight = Decimal.Parse(reader["Weight"].ToString()); * product.DaysToManufacture = Int32.Parse(reader["DaysToManufacture"].ToString()); * product.ProductLine = reader["ProductLine"].ToString(); * product.Class = reader["Class"].ToString(); * product.Style = reader["Style"].ToString(); * product.ProductSubcategoryID = Int32.Parse(reader["ProductSubcategoryID"].ToString()); * product.ProductModelID = Int32.Parse(reader["ProductModelID"].ToString()); * product.SellStartDate = DateTime.Parse(reader["SellStartDate"].ToString()); * product.SellEndDate= DateTime.Parse(reader["SellEndDate"].ToString()); * product.DiscontinuedDate= DateTime.Parse(reader["DiscontinuedDate"].ToString()); * product.ModifiedDate= DateTime.Parse(reader["ModifiedDate"].ToString()); * product.PrimaryVendorId = Int32.Parse(reader["PrimaryVendorId"].ToString()); * product.SecondaryVendorId = Int32.Parse(reader["SecondaryVendorId"].ToString()); * product.ActiveFlag = Boolean.Parse(reader["ActiveFlag"].ToString()); * product.Comments = reader["Comments"].ToString(); * * cols.Add(product);*/ } } catch (Exception ex) { log.Write(ex.Message, "GetProductDynamicCollection"); throw (ex); } finally { if (reader != null) { reader.Close(); } dbm.Dispose(); } return(cols); }
/// <summary> /// 查询产品 所有数据 /// </summary> /// <param name="pc_id"></param> /// <param name="startRowIndex"></param> /// <param name="maximumRows"></param> /// <returns>ProductCollection 包含所有记录</returns> public static ProductCollection GetList(int pc_id, int startRowIndex, int maximumRows) { int iStartRowIndex = -1; int iMaximumRows = -1; if (startRowIndex > 0 && maximumRows > 0) { iStartRowIndex = startRowIndex; iMaximumRows = maximumRows; } ProductCollection list = new ProductCollection(); string sql = @"SELECT prod_id, prod_name, prod_number, prod_price, prod_image, prod_content, prod_date, prod_click, istop, iscommend, pc_id FROM ( select *, (select ifnull(sum(1) + 1, 1) from t_product where (?pc_id=0 or pc_id=?pc_id) and prod_id > a.prod_id) as row_rank from t_product a where ?pc_id=0 or pc_id in (select pc_id from (select pc_id from t_productclass where pc_id=?pc_id union all select p.pc_id from t_productclass p inner join (select pc_id from t_productclass where pc_id=?pc_id) t on p.parent_id = t.pc_id) as temp) order by prod_id desc ) as ProductWithRowNumbers where ((row_rank between ?start_row_index AND ?start_row_index + ?maximum_rows - 1) OR ?start_row_index = -1 OR ?maximum_rows = -1);"; MySqlParameter[] parms = { new MySqlParameter("?pc_id",MySqlDbType.Int32), new MySqlParameter("?start_row_index",MySqlDbType.Int32), new MySqlParameter("?maximum_rows",MySqlDbType.Int32) }; parms[0].Value = pc_id; parms[1].Value = iStartRowIndex; parms[2].Value = iMaximumRows; MySqlDataReader reader = DbHelper.ExecuteDataReader(sql, parms); if (reader.HasRows) { list = new ProductCollection(); while (reader.Read()) { list.Add(FillDataRecord(reader)); } } reader.Close(); return list; }
/// <summary> /// 条件查询产品 /// </summary> /// <param name="istop">置顶</param> /// <param name="iscommend">推荐</param> /// <returns>ProductCollection 包含条件查询的记录</returns> public static ProductCollection GetList(bool istop, bool iscommend) { bool bIsTop = false; bool bIsCommend = false; if (istop) { bIsTop = istop; } if (iscommend) { bIsCommend = iscommend; } ProductCollection list = null; string sql = "select * from t_product where IsTop=?IsTop and IsCommend=?IsCommend"; MySqlParameter[] parms = { new MySqlParameter("?IsTop",MySqlDbType.Bit), new MySqlParameter("?IsCommend",MySqlDbType.Bit) }; parms[0].Value = bIsTop; parms[1].Value = bIsCommend; MySqlDataReader reader = DbHelper.ExecuteDataReader(sql, parms); if (reader.HasRows) { list = new ProductCollection(); while (reader.Read()) { list.Add(FillDataRecord(reader)); } } reader.Close(); return list; }
protected void Page_Load(object sender, EventArgs e) { //Some checks - We need a good confid if (Request.QueryString["confid"] == null) { Utils.ResetSessions(); Response.Redirect("default.aspx?redirect=cart", true); } else { strConfId = Request.QueryString["confid"].ToString(); } if (strConfId.Length > 4 || strConfId == "") //potentially an intrusion { Utils.ResetSessions(); Response.Redirect("default.aspx?redirect=cart", true); } //End of checks ImgBtnContinueSearch.Attributes.Add("onmousedown", "this.src='images/continuered_on.jpg'"); ImgBtnContinueSearch.Attributes.Add("onmouseup", "this.src='images/continuered_off.jpg'"); ImgBtnCancelOrder.Attributes.Add("onmousedown", "this.src='images/cancel_on.jpg'"); ImgBtnCancelOrder.Attributes.Add("onmouseup", "this.src='images/cancel_off.jpg'"); ImgBtnCheckOut.Attributes.Add("onmousedown", "this.src='images/checkout_on.jpg'"); ImgBtnCheckOut.Attributes.Add("onmouseup", "this.src='images/checkout_off.jpg'"); //***EAC Hide buttons or not...Better to do on PageLoad for each page than in Master.cs! Master.FindControl("btnViewCart").Visible = false; //Master.FindControl("btnSearchOther").Visible = false; Master.FindControl("btnFinish").Visible = false; Master.FindControl("lblFreePubsInfo").Visible = false; //Check whether the conference is domestic or international if (Session["KIOSK_ShipLocation"] != null) { if (Session["KIOSK_ShipLocation"].ToString().Length > 0) { if (string.Compare(Session["KIOSK_ShipLocation"].ToString(), "Domestic", true) == 0) { hdnTotalLimit.Value = ConfigurationManager.AppSettings["DomesticOrderLimit"]; } else if (string.Compare(Session["KIOSK_ShipLocation"].ToString(), "International", true) == 0) { //hdnTotalLimit.Value = ConfigurationManager.AppSettings["InternationalOrderLimit"]; hdnTotalLimit.Value = PubEnt.DAL.DAL.GetIntl_MaxOrder(int.Parse(strConfId)).ToString(); } } } if (!IsPostBack) { #region dummydata2--remove before going live if (Request.QueryString["debug"] == "yes") { Session["KIOSK_Pubs"] = "4236,1095,1169"; Session["KIOSK_Qtys"] = "1,14,1"; Session["KIOSK_Urls"] = "34,47,110,116,117,118,119,120,121,122,123,124,127,128,129,130,131"; Session["KIOSK_ShipLocation"] = "Domestic"; } #endregion this.shoppingcart = null; //destroy cart if it exists this.shoppingcart = new ProductCollection(); //***EAC Parse the KIOSK_Pubs and KIOSK_qtys..assume they have same dimensions string[] pubs = Session["KIOSK_Pubs"].ToString().Split(new Char[] { ',' }); string[] qtys = Session["KIOSK_Qtys"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < pubs.Length; i++) { if (pubs[i].Trim() != "") { int pubid = Int32.Parse(pubs[i]); Product p = Product.GetPubByPubID(pubid); p.NumQtyOrdered = Int32.Parse(qtys[i]); p.IsPhysicalItem = true; shoppingcart.Add(p); //TODO: BLL Add should differentiate physical from virtual items while deduping } } #region EAC Add ONLINE-only items to the shopping cart (20130226) //***EAC We are assuming Session_pubs and Session_Urls are mutually exclusive string[] urls = Session["KIOSK_Urls"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < urls.Length; i++) { if (urls[i].Trim() != "") { int pubid = Int32.Parse(urls[i]); Product p = Product.GetPubByPubID(pubid); p.NumQtyOrdered = 1; p.IsPhysicalItem = false; shoppingcart.Add(p); //TODO: BLL Add should differentiate physical from virtual items while deduping } } #endregion //--- Sorting the publication collection by long title this.shoppingcart.Sort(ProductCollection.ProductFields.LongTitle, true); grdViewItems.DataSource = this.shoppingcart; grdViewItems.DataBind(); //Add client code //ImgBtnCancelOrder.Attributes.Add("onclick", "return fnAskBeforeCancelling(" + "'" + ImgBtnCancelOrder.ClientID + "')"); } //Check for cart object here if (this.shoppingcart == null) { //Display empty shopping cart Panel1.Visible = false; Panel2.Visible = true; ImgBtnCheckOut.Visible = false; } else { if (this.shoppingcart.Count > 0 && hdnTotalLimit.Value.Length > 0) { //***EAC at this point we have a usable cart lblTot.Text = this.shoppingcart.TotalQtyForShipping.ToString(); lblFreeRemaining.Text = (Int32.Parse(hdnTotalLimit.Value) - this.shoppingcart.TotalQtyForShipping).ToString(); Panel1.Visible = true; Panel2.Visible = false; if (Session["KIOSK_ShipLocation"].ToString() != "Domestic") { h3free.Visible = false; trFreeRemain.Visible = false; spanQty.Visible = false; trTotalItems.Visible = false; } } else//shopping cart is empty { Panel1.Visible = false; Panel2.Visible = true; ImgBtnCheckOut.Visible = false; } } }
/// <summary> /// Handles the UserDeletingRow event of the _productsGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewRowCancelEventArgs"/> instance containing the event data.</param> private void _productsGrid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { // add to the detele requests collection _productsToDelete.Add((ProductEntity)e.Row.DataBoundItem); }
/// <summary> /// Creates the product collection. /// </summary> /// <returns></returns> private static ProductCollection CreateProductCollection() { ProductCollection c = new ProductCollection(); for(int i = 0; i < 1000; i++) c.Add(CreateProduct(i)); Assert.AreEqual(1000, c.Count, "Before Save"); return c; }
public void _0001_Test() { SupplierCollection suppliers = new SupplierCollection(); suppliers.Add(new SuplierItem(1, "Lomex")); suppliers.Add(new SuplierItem(2, "TME")); suppliers.Add(new SuplierItem(3, "Farnell")); suppliers.Add(new SuplierItem(4, "CBA")); ProductCollection products = new ProductCollection(); products.Add(new ProductItem(1, "1N4148", "Dióda", 1)); products.Add(new ProductItem(2, "BC128", "Tranzisztor", 1)); products.Add(new ProductItem(3, "AT90CAN128", "Processzor", 2)); products.Add(new ProductItem(4, "ESD szönyeg", "ESD Védelem", 2)); //products.Add(new ProductItem(5, "Henkel On", "Forrasztás", 3)); //products.Add(new ProductItem(6, "Weller WP szürő", "Egészség", 3)); //products.Add(new ProductItem(7, "Banán", "Gyümölcs", 2)); /*Data SET*/ DataSet dataSet = new DataSet("DemoDataSet"); /*Suppliers*/ /*SupplierId-PK,SupplierName*/ DataTable suppliersDt = ToDataTable(suppliers, "Suppliers"); suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["SupplierId"] }; dataSet.Tables.Add(suppliersDt); /*Products*/ /*ProductId-PK, ProductName, Description, SupplierId*/ DataTable productsDt = ToDataTable(products, "Products"); suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["ProductId"] }; DataColumn supplierNameColumn = new DataColumn("SupplierName", typeof(string)); productsDt.Columns.Add(supplierNameColumn); dataSet.Tables.Add(productsDt); /* */ DataRelation productsSuppliersRelation = dataSet.Relations.Add("ProductSuppliers", dataSet.Tables["Suppliers"].Columns["SupplierId"], dataSet.Tables["Products"].Columns["SupplierId"], true); dataSet.AcceptChanges(); DataGrid dg = new DataGrid(); dg.SetDataBinding(dataSet, "Products"); var form = new Form2(); form.dataGridView1.DataSource = dataSet; form.dataGridView1.DataMember = "Products"; form.dataGridView2.DataSource = dataSet; form.dataGridView2.DataMember = "Suppliers"; Application.Run(form); }
public ProductCollection GetDetailedProduct(int pid) { IPrefetchPath prefatchPath = new PrefetchPath(EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathComments).Filter.Add(CommentFields.Status == true); prefatchPath.Add(ProductEntity.PrefetchPathProductKeywords); prefatchPath.Add(ProductEntity.PrefetchPathProductSpecifications); prefatchPath.Add(ProductEntity.PrefetchPathProductPhotos); ProductEntity p = new ProductEntity(pid, prefatchPath); ProductCollection col = new ProductCollection(); col.Add(p); return col; }