private void product_Click(object sender, System.EventArgs e) { int index = Convert.ToInt32( ((Button)sender).Name.Split()[1]); ProductToSell product = new ProductToSell(); product.ActualProduct = POS.Products.Get(index); POS.MoveToTableProducts(product); DrawTableProducts(); }
public int IndexOf(ProductToSell product) { for (int i = 0; i < Count; i++) { if (ProductsToSell[i].ActualProduct.Code == product.ActualProduct.Code) { return(i); } } return(0); }
public bool Contains(ProductToSell product) { for (int i = 0; i < Count; i++) { if (ProductsToSell[i].ActualProduct.Code == product.ActualProduct.Code) { return(true); } } return(false); }
private void btnAdd_Click(object sender, System.EventArgs e) { int index = Convert.ToInt32( ((Button)sender).Name.Split()[1]); TableProductsList Products = POS.GetTableProducts(); ProductToSell product = new ProductToSell(); product.ActualProduct = Products.Get(index).ActualProduct; POS.AddTableProduct(product); DrawTableProducts(); }
private void pnlProductToSell_Click(object sender, System.EventArgs e) { int index = Convert.ToInt32( ((Label)sender).Name.Split()[1]); ProductToSellList Products = POS.GetProductsToSell(); ProductToSell product = new ProductToSell(); product.ActualProduct = Products.Get(index).ActualProduct; POS.MoveToTableProducts(product); POS.SubstractProductToSell(product); DrawProductsToSell(); DrawTableProducts(); }
private void DrawProductsToSell() { pnlProductsToSell.Controls.Clear(); this.lblWorker.Text = POS.Employee.Code.ToString("000"); this.lblTableNumber.Text = POS.Index.ToString(); ProductToSellList products = POS.GetProductsToSell(); double subtotal = products.CalculeTotal(); this.lblSubtotal.Text = subtotal.ToString("0.00"); double iva = subtotal * 0.21; POS.Total = subtotal + iva; this.lblVA.Text = iva.ToString("0.00"); this.lblTotal.Text = POS.Total.ToString("0.00"); for (int i = 1; i <= products.Count; i++) { ProductToSell product = products.Get(i); // // lblDescription // Label lblDescription = new Label(); lblDescription.BackColor = System.Drawing.Color.White; lblDescription.BorderStyle = BorderStyle.FixedSingle; lblDescription.FlatStyle = FlatStyle.Popup; lblDescription.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblDescription.Location = new System.Drawing.Point(-3, 0); lblDescription.Name = "label " + i; lblDescription.Size = new System.Drawing.Size(138, 33); lblDescription.TabIndex = 51; lblDescription.Text = product.ActualProduct.Description; lblDescription.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; lblDescription.Click += new EventHandler(pnlProductToSell_Click); // // lblPrice // Label lblPrice = new Label(); lblPrice.BackColor = System.Drawing.Color.White; lblPrice.BorderStyle = BorderStyle.FixedSingle; lblPrice.FlatStyle = FlatStyle.Popup; lblPrice.Font = new System.Drawing.Font("Arial", 9.75F); lblPrice.Location = new System.Drawing.Point(135, 0); lblPrice.Name = "label " + i; lblPrice.Size = new System.Drawing.Size(85, 33); lblPrice.TabIndex = 52; lblPrice.Text = product.ActualProduct.Price.ToString(); lblPrice.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; lblPrice.Click += new EventHandler(pnlProductToSell_Click); // // lblAmount // Label lblAmount = new Label(); lblAmount.BackColor = System.Drawing.Color.White; lblAmount.BorderStyle = BorderStyle.FixedSingle; lblAmount.FlatStyle = FlatStyle.Popup; lblAmount.Font = new System.Drawing.Font("Arial", 9.75F); lblAmount.Location = new System.Drawing.Point(220, 0); lblAmount.Name = "label " + i; lblAmount.Size = new System.Drawing.Size(108, 33); lblAmount.TabIndex = 50; lblAmount.Text = product.Amount.ToString(); lblAmount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; lblAmount.Click += new EventHandler(pnlProductToSell_Click); // // pnlProductToSell // Panel pnlProductToSell = new Panel(); pnlProductToSell.BackColor = System.Drawing.Color.DimGray; pnlProductToSell.BorderStyle = BorderStyle.Fixed3D; pnlProductToSell.Controls.Add(lblAmount); pnlProductToSell.Controls.Add(lblPrice); pnlProductToSell.Controls.Add(lblDescription); pnlProductToSell.ForeColor = System.Drawing.Color.Black; pnlProductToSell.Location = new System.Drawing.Point(0, 0 + ((i - 1) * 33)); pnlProductToSell.Name = "pnlPayProduct"; pnlProductToSell.Size = new System.Drawing.Size(330, 33); pnlProductToSell.TabIndex = 53; pnlProductsToSell.Controls.Add(pnlProductToSell); } }
private void DrawTableProducts() { pnlTableProducts.Controls.Clear(); this.lblWorker.Text = POS.Employee.Code.ToString("000"); this.lblTableNumber.Text = POS.Index.ToString(); TableProductsList products = POS.GetTableProducts(); for (int i = 1; i <= products.Count; i++) { ProductToSell actualProduct = products.Get(i); // // btnSubstract // Button btnSubstract = new Button(); btnSubstract.BackColor = System.Drawing.Color.White; btnSubstract.FlatAppearance.BorderColor = System.Drawing.Color.Black; btnSubstract.FlatStyle = FlatStyle.Popup; btnSubstract.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); btnSubstract.Location = new System.Drawing.Point(56, 110); btnSubstract.Name = "btnSubstract " + i; btnSubstract.Size = new System.Drawing.Size(33, 33); btnSubstract.TabIndex = 80; btnSubstract.Text = "-"; btnSubstract.UseVisualStyleBackColor = false; btnSubstract.Click += new System.EventHandler(btnSubstract_Click); // // btnAdd // Button btnAdd = new Button(); btnAdd.BackColor = System.Drawing.Color.White; btnAdd.FlatAppearance.BorderColor = System.Drawing.Color.Black; btnAdd.FlatStyle = FlatStyle.Popup; btnAdd.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); btnAdd.Location = new System.Drawing.Point(56, 78); btnAdd.Name = "btnAdd " + i; btnAdd.Size = new System.Drawing.Size(33, 33); btnAdd.TabIndex = 81; btnAdd.Text = "+"; btnAdd.UseVisualStyleBackColor = false; btnAdd.Click += new System.EventHandler(btnAdd_Click); // // lblAmount // Label lblAmount = new Label(); lblAmount.BackColor = System.Drawing.Color.White; lblAmount.BorderStyle = BorderStyle.FixedSingle; if (actualProduct.Amount > 99) { lblAmount.Font = new System.Drawing.Font("Arial", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); } else { lblAmount.Font = new System.Drawing.Font("Arial", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); } lblAmount.Location = new System.Drawing.Point(-9, 78); lblAmount.Name = "label15"; lblAmount.Size = new System.Drawing.Size(68, 65); lblAmount.TabIndex = 82; lblAmount.Text = actualProduct.Amount.ToString(); lblAmount.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // btnImage // Button pbImage = new Button(); pbImage.BackColor = System.Drawing.Color.White; pbImage.Location = new System.Drawing.Point(-2, -2); pbImage.Name = "pbImage " + i; pbImage.Size = new System.Drawing.Size(100, 80); pbImage.TabIndex = 79; pbImage.TabStop = false; try { pbImage.BackgroundImage = System.Drawing.Image.FromFile( actualProduct.ActualProduct.ImagePath); } catch (Exception) { pbImage.Text = actualProduct.ActualProduct.Description; } pbImage.BackgroundImageLayout = ImageLayout.Zoom; pbImage.Click += new System.EventHandler(btnTableProduct_Click); // //Panel container // Panel tableProduct = new Panel(); tableProduct.BorderStyle = BorderStyle.Fixed3D; tableProduct.Controls.Add(btnAdd); tableProduct.Controls.Add(btnSubstract); tableProduct.Controls.Add(lblAmount); tableProduct.Controls.Add(pbImage); tableProduct.Location = new System.Drawing.Point(0 + ((i - 1) * 90), 0); tableProduct.Name = "pnl " + i; tableProduct.Size = new System.Drawing.Size(90, 145); tableProduct.TabIndex = 85; pnlTableProducts.Controls.Add(tableProduct); } }
public void Remove(ProductToSell product) { ProductsToSell.RemoveAt(IndexOf(product)); }
public ProductToSell Get(ProductToSell product) { return(ProductsToSell[IndexOf(product)]); }
public void Add(ProductToSell product) { ProductsToSell.Add(product); }