Пример #1
0
        public void AddProductsToTabbedPanel()
        {
            int i = 1;

            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                foreach (TabPage item in metroTabControl1.TabPages)
                {
                    FlowLayoutPanel flp = new FlowLayoutPanel();
                    flp.Dock = DockStyle.Fill;
                    foreach (var product in cpe.TblProducts)
                    {
                        if (product.ProductType == i)
                        {
                            Button btn = new Button();
                            btn.Size       = new Size(100, 100);
                            btn.Image      = Image.FromStream(new MemoryStream(product.Image));
                            btn.ImageAlign = ContentAlignment.TopCenter;
                            btn.TextAlign  = ContentAlignment.BottomCenter;
                            btn.ImageAlign = ContentAlignment.TopCenter;
                            btn.Tag        = product;

                            btn.Click += Btn_Click;

                            btn.Text      = product.Description;
                            btn.BackColor = Color.White;
                            flp.Controls.Add(btn);
                        }
                    }

                    item.Controls.Add(flp);
                    i++;
                }
            }
        }
Пример #2
0
        public void TransactionCompletedMethod(object sebder, EventArgs e)
        {
            this.Refresh();
            lblTotal.Text = String.Format("Total to Pay: {0:C}", totalToPay);

            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                if (ChosenProductsList.Count > 0)
                {
                    TblTransaction transaction = new TblTransaction();
                    transaction.TransactionDate = DateTime.Now;
                    foreach (var item in ChosenProductsList)
                    {
                        transaction.TblTransactionItems.Add(new TblTransactionItem()
                        {
                            ProductID = item.ProductID
                        });
                    }

                    cpe.TblTransactions.Add(transaction);
                    try
                    {
                        cpe.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            PrintReciept();
        }
        public void ContentClickDisplay()
        {
            int selectedProductId = 0;

            for (int i = 0; i < productGridView.Rows.Count; i++)
            {
                if (productGridView.Rows[i].Selected == true)
                {
                    selectedProductId = (int)productGridView.Rows[i].Cells[0].Value;
                }
            }

            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                var recievedImage = from m in cpe.TblProducts
                                    select m;
                foreach (var item in recievedImage)
                {
                    if (item.ProductID == selectedProductId)
                    {
                        lblDescription.Visible = true;
                        lblPrice.Visible       = true;
                        txtDescription.Visible = true;
                        byte[]       imagedBytes  = item.Image;
                        MemoryStream memoryStream = new MemoryStream(imagedBytes);
                        selectedImage.Image = Image.FromStream(memoryStream);
                        txtDescription.Text = item.Description;
                        lblPrice.Text       = String.Format("{0:C}", item.Price);
                        break;
                    }
                }
            }
        }
Пример #4
0
 public void CreateTabbedPanel()
 {
     using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
     {
         foreach (var item in cpe.TblProductTypes)
         {
             metroTabControl1.TabPages.Add(item.ProductType.ToString(), item.ProductDescription);
         }
     }
 }
        public void DisplayAllData()
        {
            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                DataTable tempTable = new DataTable();
                tempTable.Columns.Add("Id", typeof(int));
                tempTable.Columns.Add("Product Type", typeof(int));
                tempTable.Columns.Add("Decription", typeof(string));
                tempTable.Columns.Add("Price", typeof(string));

                var items = cpe.TblProducts.Select(it => it);
                foreach (var item in items)
                {
                    tempTable.Rows.Add(item.ProductID, item.ProductType, item.Description, item.Price);
                }
                productGridView.DataSource = tempTable;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                TblProduct newProduct = new TblProduct()
                {
                    Description = txtDescription.Text,
                    Price       = Convert.ToDecimal(txtPrice.Text),
                    Image       = imageBytes,
                    ProductType = (int)cmbCategory.SelectedValue
                };

                cpe.TblProducts.Add(newProduct);
                cpe.SaveChanges();
                lblSaving.Visible = false;
                MessageBox.Show("Item Saved Successfully", "Item Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void Add_Product_Load(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("rs-PK");

            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                DataTable temptabel = new DataTable();
                temptabel.Columns.Add("ProductType", typeof(int));
                temptabel.Columns.Add("ProductDescription", typeof(string));

                var items = cpe.TblProductTypes.Select(eb => eb);
                foreach (var item in items)
                {
                    temptabel.Rows.Add((int)item.ProductType, (string)item.ProductDescription);
                }

                cmbCategory.DataSource    = temptabel;
                cmbCategory.DisplayMember = "ProductDescription";
                cmbCategory.ValueMember   = "ProductType";
            }
        }
Пример #8
0
        private void GenerateGraph()
        {
            try
            {
                using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
                {
                    var query = from product in cpe.TblTransactionItems
                                group product by product.TblProduct.Description into g
                                select new { ProductId = g.Key, TotalUnitSold = g.Count() };
                    var list = query.ToList();

                    chart1.DataSource = list;
                    chart1.Series["Series1"].XValueMember  = "ProductId";
                    chart1.Series["Series1"].YValueMembers = "TotalUnitSold";
                    chart1.Series["Series1"].Name          = "Products";
                    chart1.DataBind();
                    chart1.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }