Exemple #1
0
        public Receipt()
        {
            Text          = "Shopping Cart made by M & M 2017";
            Size          = new Size(600, 550);
            StartPosition = FormStartPosition.CenterScreen;


            TableLayoutPanel mainTableReceipt = new TableLayoutPanel
            {
                ColumnCount = 3,
                RowCount    = 7,
                Dock        = DockStyle.Fill,
                BackColor   = Color.LightCyan
            };

            mainTableReceipt.Controls.Add(Projekt_1.DataGridView2, 1, 3);


            //Design.
            Controls.Add(mainTableReceipt);
            mainTableReceipt.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10));
            mainTableReceipt.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80));
            mainTableReceipt.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10));

            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 2));
            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 10));
            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 8));
            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 58));
            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 8));
            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 12));
            mainTableReceipt.RowStyles.Add(new RowStyle(SizeType.Percent, 2));



            //Creation of Labels from method in another file.
            var receipt = VisualItems.CreateLabel("Receipt", 28, (AnchorStyles.Top));

            mainTableReceipt.Controls.Add(receipt, 1, 1);

            var confirmed = VisualItems.CreateLabel("You purchase has been confirmed.", 14, AnchorStyles.Top);

            mainTableReceipt.Controls.Add(confirmed, 1, 2);


            Projekt_1.LabelTotalPay.Text = "Total: " + Projekt_1.LabelTotalPay.Text;
            mainTableReceipt.Controls.Add(Projekt_1.LabelTotalPay, 1, 4);


            //Creation of buttons from method in another file.
            var buttonClose = VisualItems.CreateButton("Close");

            mainTableReceipt.Controls.Add(buttonClose, 1, 5);



            //Eventhandelers
            buttonClose.Click += ButtonClose_Click;
        }
Exemple #2
0
        public static DataGridView DataGridFromFile(string path)
        {
            DataGridView dataGridView = VisualItems.CreateDataGridView();

            //string[] words = WordsFrom(path);
            //dataGridView.Rows.Add(words);
            string[] lines = File.ReadAllLines(path);
            foreach (string line in lines)
            {
                string[] words = line.Split(',');
                dataGridView.Rows.Add(words);
            }
            return(dataGridView);
        }
Exemple #3
0
        public Projekt_1()
        {
            DataGridView1 = FileHandler.DataGridFromFile(@"Products.csv");

            Text          = "Shopping Cart made by M & M 2017";
            Size          = new Size(1000, 620);
            StartPosition = FormStartPosition.CenterScreen;

            //Creation of tables
            var mainTable = VisualItems.CreateTableLayoutPanel(3, 5, Color.LightCyan);
            var removeAndClearCartTable = VisualItems.CreateTableLayoutPanel(2, 1, Color.LightCyan);
            var sumAndValidateTable     = VisualItems.CreateTableLayoutPanel(2, 6, Color.LightSkyBlue);

            //Creation of buttons from method in another file.
            var buttonAddToCart     = VisualItems.CreateButton("Add to Cart");
            var buttonCheckout      = VisualItems.CreateButton("CHECKOUT");
            var buttonRemoveProduct = VisualItems.CreateButton("Remove");
            var buttonClearCart     = VisualItems.CreateButton("Clear Cart");
            var buttonValidate      = VisualItems.CreateButton("Validate");

            //Creation of Labels from method in another file.
            var shoppingCart         = VisualItems.CreateLabel("Shopping Cart", 20, AnchorStyles.Bottom);
            var labelProducts        = VisualItems.CreateLabel("Products", 20, AnchorStyles.Bottom);
            var labelTotalInCart     = VisualItems.CreateLabel("Total in cart:", 12, AnchorStyles.Bottom);
            var labelTotalToPay      = VisualItems.CreateLabel("Total to pay:", 12, AnchorStyles.Bottom);
            var labelEnterCouponCode = VisualItems.CreateLabel("Enter coupon code:", 12, AnchorStyles.Bottom);

            //Design
            Controls.Add(mainTable);
            mainTable.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 225));
            mainTable.RowStyles.Add(new RowStyle(SizeType.Percent, 4));
            mainTable.RowStyles.Add(new RowStyle(SizeType.Percent, 10));
            mainTable.RowStyles.Add(new RowStyle(SizeType.Percent, 70));
            mainTable.RowStyles.Add(new RowStyle(SizeType.Percent, 12));
            mainTable.RowStyles.Add(new RowStyle(SizeType.Percent, 4));
            mainTable.Controls.Add(DataGridView2, 1, 2);
            mainTable.Controls.Add(labelProducts, 0, 1);
            mainTable.Controls.Add(shoppingCart, 1, 1);
            mainTable.Controls.Add(DataGridView1, 0, 2);
            mainTable.Controls.Add(buttonAddToCart, 0, 3);
            mainTable.Controls.Add(buttonCheckout, 2, 3);
            mainTable.SetColumnSpan(buttonCheckout, 1);
            mainTable.Controls.Add(removeAndClearCartTable, 1, 3);
            mainTable.Controls.Add(sumAndValidateTable, 2, 2);

            removeAndClearCartTable.Controls.Add(buttonRemoveProduct, 0, 0);
            removeAndClearCartTable.Controls.Add(buttonClearCart, 1, 0);

            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Percent, 12));
            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Percent, 10));
            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Percent, 14));
            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Percent, 12));
            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Percent, 20));
            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Percent, 41));
            sumAndValidateTable.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
            sumAndValidateTable.Controls.Add(labelTotalInCart, 0, 0);
            sumAndValidateTable.Controls.Add(labelTotalToPay, 0, 6);
            sumAndValidateTable.Controls.Add(labelEnterCouponCode, 0, 2);
            sumAndValidateTable.Controls.Add(LabelTotalPayCart, 1, 0);
            sumAndValidateTable.Controls.Add(TextBoxForCoupon, 1, 2);
            sumAndValidateTable.Controls.Add(buttonValidate, 1, 3);
            sumAndValidateTable.Controls.Add(LabelTotalPay, 1, 6);
            sumAndValidateTable.SetColumnSpan(labelEnterCouponCode, 2);
            sumAndValidateTable.SetColumnSpan(TextBoxForCoupon, 2);
            sumAndValidateTable.SetColumnSpan(buttonValidate, 2);

            //Eventhandelers
            buttonAddToCart.Click          += DataGridView1_SelectionRowAdd;
            buttonRemoveProduct.Click      += DataGridView2_SelectionRowDelete;
            buttonClearCart.Click          += DataGridView2_ClearCart;
            DataGridView2.CellValueChanged += DataGridView2_CellValueChanged;
            buttonValidate.Click           += ButtonValidate_Click;
            buttonCheckout.Click           += ButtonCheckout_Click;
        }