private void uAddButton_Click(object sender, EventArgs e)
        {
            if (uFirstnameTextBox.Text == "" || uLastNameTextBox.Text == "" || uEmailTextBox.Text == "" || uPhoneTextBox.Text == "" || uPasswordTextBox.Text == "" || uAddressTextBox.Text == "")
            {
                MessageBox.Show("please fill up all info except User ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Customer c = new Customer()
                {
                    C_Firstname = uFirstnameTextBox.Text,
                    C_Lastname  = uLastNameTextBox.Text,
                    //C_ID =Convert.ToInt32(uUserIDTextBox.Text),
                    C_Password = Convert.ToInt32(uPasswordTextBox.Text),
                    C_Email    = uEmailTextBox.Text,
                    C_Phone    = uPhoneTextBox.Text,
                    C_Address  = aAddressTextBox.Text
                };
                scdc.Customers.InsertOnSubmit(c);
                scdc.SubmitChanges();
                UserlistGridViewUpdate();
                uFirstnameTextBox.Text = uLastNameTextBox.Text = uPasswordTextBox.Text = uEmailTextBox.Text = uPhoneTextBox.Text = uAddressTextBox.Text = string.Empty;
            }
        }
        private void insertButton_Click(object sender, EventArgs e)
        {
            if (productNameTextBox.Text == "" || productdesTextbox.Text == "" || productPriceTextBox.Text == "" || stockTextBox.Text == "" || categoryComboBox.Text == "")
            {
                MessageBox.Show("please fill up all information except PRODUCT ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");


                Product  p   = new Product();
                Category cat = new Category();
                p.P_Name  = productNameTextBox.Text;
                p.P_Price = Convert.ToDouble(productPriceTextBox.Text);
                p.P_Stock = Convert.ToInt32(stockTextBox.Text);
                p.P_Des   = productdesTextbox.Text;
                p.Cat_ID  = int.Parse(categoryComboBox.Text);

                /*if (categoryComboBox.Text == cat.Cat_Name)
                 *  {
                 *      p.Cat_ID = cat.Cat_ID;
                 *  }*/


                scdc.Products.InsertOnSubmit(p);
                scdc.SubmitChanges();
                productListGridViewUpdate();

                productNameTextBox.Text = productidTextBox.Text = productPriceTextBox.Text = productdesTextbox.Text = stockTextBox.Text = categoryComboBox.Text = string.Empty;
                MessageBox.Show("PRODUCT ADDED SUCCESSFULLY");
            }
        }
        private void uUpdateButton_Click(object sender, EventArgs e)
        {
            if (uFirstnameTextBox.Text == "" || uUserIDTextBox.Text == "" || uLastNameTextBox.Text == "" || uEmailTextBox.Text == "" || uPhoneTextBox.Text == "" || uPasswordTextBox.Text == "" || uAddressTextBox.Text == "")
            {
                MessageBox.Show("please fill up all info");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Customer c = scdc.Customers.SingleOrDefault(x => x.C_ID == int.Parse(uUserIDTextBox.Text));

                c.C_Firstname = uFirstnameTextBox.Text;
                c.C_Lastname  = uLastNameTextBox.Text;
                c.C_Email     = uEmailTextBox.Text;
                c.C_Password  = Convert.ToInt32(uPasswordTextBox.Text);
                c.C_Phone     = uPhoneTextBox.Text;
                c.C_Address   = uAddressTextBox.Text;

                scdc.SubmitChanges();
                UserlistGridViewUpdate();

                uUserIDTextBox.Text = string.Empty;
            }
        }
        private void searchButton_Click(object sender, EventArgs e)
        {
            if (productidTextBox.Text == "")
            {
                MessageBox.Show("please insert a valid PRODUCT ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                var x = from a in scdc.Products
                        join b in scdc.Categories
                        on a.Cat_ID equals b.Cat_ID
                        where a.P_ID == int.Parse(productidTextBox.Text)
                        select new { a.P_Name, a.P_Price, a.P_Stock, a.P_Des, a.Cat_ID, b.Cat_Name };
                productNameTextBox.Text  = x.FirstOrDefault().P_Name;
                productPriceTextBox.Text = Convert.ToString(x.FirstOrDefault().P_Price);
                stockTextBox.Text        = Convert.ToString(x.FirstOrDefault().P_Stock);
                productdesTextbox.Text   = x.FirstOrDefault().P_Des;
                //categoryComboBox.Text= (Convert.ToString(x.FirstOrDefault().Cat_Name));
                categoryComboBox.Text = Convert.ToString(x.FirstOrDefault().Cat_ID);

                productDatagridView.DataSource = x.ToList();
            }
        }
        private void aEditButton_Click(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            Customer u2 = scdc.Customers.SingleOrDefault(x => x.C_ID == pp.id);

            u2.C_Firstname = cFirstnameTextBox.Text;
            u2.C_Lastname  = cLastnameTextBox.Text;
            u2.C_ID        = int.Parse(cUserIDTextBox.Text);
            u2.C_Password  = int.Parse(cPasswordTextBox.Text);
            u2.C_Email     = cEmailTextBox.Text;
            u2.C_Phone     = cPhoneTextBox.Text;
            u2.C_Address   = cAddressTextBox.Text;


            scdc.SubmitChanges();


            fnameLabel.Text    = u2.C_Firstname;
            lanameLabel.Text   = u2.C_Lastname;
            emailLabel.Text    = u2.C_Email;
            phoneLabel.Text    = u2.C_Phone;
            addressLabel.Text  = u2.C_Address;
            idLabel.Text       = Convert.ToString(u2.C_ID);
            passwordLabel.Text = Convert.ToString(u2.C_Password);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            productNameTextBox.Text = productidTextBox.Text = productPriceTextBox.Text = productdesTextbox.Text = stockTextBox.Text = categoryComboBox.Text = string.Empty;

            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            categorydataGridView2.DataSource = scdc.Categories;

            productListGridViewUpdate();
        }
        public AdminHome(person p)
        {
            pp = p;
            InitializeComponent();

            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            categoryComboBox.DataSource    = scdc.Categories;
            categoryComboBox.DisplayMember = "Cat_ID";
            categoryComboBox.ValueMember   = "Cat_ID";
        }
        private void Shopping_List_FormClosing(object sender, FormClosingEventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");
            Transaction             t    = new Transaction();
            var s = from a in scdc.Transactions
                    select a;

            scdc.Transactions.DeleteAllOnSubmit(s);
            scdc.SubmitChanges();
            Application.Exit();
        }
        private void AdminHome_Load(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            //To show CUSTOMER LIST on gridview
            userlistDataGridView.DataSource = scdc.Customers;
            //To show CATEGORY LIST on gridView
            categoryDataGridView.DataSource = scdc.Categories;

            categorydataGridView2.DataSource = scdc.Categories;
            //Loadin ADMIN INFORMATION tab
            AdminLogin al = new AdminLogin();

            Admin a2 = scdc.Admins.SingleOrDefault(x => x.A_ID == pp.id);

            // on textbox
            aFirstnameTextBox.Text = a2.A_Firstname;
            aLastnameTextBox.Text  = a2.A_Lastname;
            aUserIDTextBox.Text    = Convert.ToString(a2.A_ID);
            aPasswordTextBox.Text  = Convert.ToString(a2.A_Password);
            aEmailTextBox.Text     = a2.A_Email;
            aPhoneTextBox.Text     = a2.A_Phone;
            aAddressTextBox.Text   = a2.A_Address;

            //on table panel

            fnameLabel.Text    = a2.A_Firstname;
            lnamelabel.Text    = a2.A_Lastname;
            emaillabel.Text    = a2.A_Email;
            phonelabel.Text    = a2.A_Phone;
            addresslabel.Text  = a2.A_Address;
            idlabel.Text       = Convert.ToString(a2.A_ID);
            passwordlabel.Text = Convert.ToString(a2.A_Password);


            //For Loading complete PRODUCT LIST on Product management tab

            var s = from a in scdc.Products
                    from b in scdc.Categories
                    where a.Cat_ID == b.Cat_ID
                    select new
            {
                Product_Name  = a.P_Name,
                Product_ID    = a.P_ID,
                Price         = a.P_Price,
                Stock         = a.P_Stock,
                CategoryID    = b.Cat_ID,
                Category_Name = b.Cat_Name
            };

            productDatagridView.DataSource = s.ToList();

            categoryComboBox.Text = string.Empty;
        }
        private void PrintButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Your list is now printing \n Thankyou for shopping with us");
            this.Close();
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");
            Transaction             t    = new Transaction();
            var s = from a in scdc.Transactions
                    select a;

            scdc.Transactions.DeleteAllOnSubmit(s);
            scdc.SubmitChanges();
        }
        private void CoustomerHome_Load(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            var s = from a in scdc.Products
                    from b in scdc.Categories
                    where a.Cat_ID == b.Cat_ID
                    select new
            {
                Product_Name = a.P_Name,

                Product_ID    = a.P_ID,
                Category_Name = b.Cat_Name,

                Price      = a.P_Price,
                Stock      = a.P_Stock,
                CategoryID = b.Cat_ID,
            };

            productGridView.DataSource = s.ToList();


            UserLogin u1 = new UserLogin();

            Customer u2 = scdc.Customers.SingleOrDefault(x => x.C_ID == pp.id);

            cFirstnameTextBox.Text = u2.C_Firstname;
            cLastnameTextBox.Text  = u2.C_Lastname;
            cUserIDTextBox.Text    = Convert.ToString(u2.C_ID);
            cPasswordTextBox.Text  = Convert.ToString(u2.C_Password);
            cEmailTextBox.Text     = u2.C_Email;
            cPhoneTextBox.Text     = u2.C_Phone;
            cAddressTextBox.Text   = u2.C_Address;



            fnameLabel.Text    = u2.C_Firstname;
            lanameLabel.Text   = u2.C_Lastname;
            emailLabel.Text    = u2.C_Email;
            phoneLabel.Text    = u2.C_Phone;
            addressLabel.Text  = u2.C_Address;
            idLabel.Text       = Convert.ToString(u2.C_ID);
            passwordLabel.Text = Convert.ToString(u2.C_Password);

            categoryComboBox.Text = string.Empty;
        }
        /*  private void productnameComboBox_SelectedIndexChanged(object sender, EventArgs e)
         * {
         *
         *
         * }
         */
        private void Search_Click(object sender, EventArgs e)
        {
            if (productIDTextBox.Text == "")
            {
                MessageBox.Show("Enter Valid Product ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                var x = from a in scdc.Products
                        where a.P_ID == int.Parse(productIDTextBox.Text)
                        select a;
                priceTextBox.Text       = Convert.ToString(x.FirstOrDefault().P_Price);
                productNameTextBox.Text = x.FirstOrDefault().P_Name;
            }
        }
        private void uSearchButton_Click(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            var x = from a in scdc.Customers
                    where a.C_ID == int.Parse(uUserIDTextBox.Text)
                    select a;

            uFirstnameTextBox.Text = x.FirstOrDefault().C_Firstname;
            uLastNameTextBox.Text  = x.FirstOrDefault().C_Lastname;
            // uUserIDTextBox.Text = Convert.ToString(x.FirstOrDefault().C_ID);
            uPasswordTextBox.Text = Convert.ToString(x.FirstOrDefault().C_Password);
            uEmailTextBox.Text    = x.FirstOrDefault().C_Email;
            uPhoneTextBox.Text    = x.FirstOrDefault().C_Phone;
            uAddressTextBox.Text  = x.FirstOrDefault().C_Address;

            userlistDataGridView.DataSource = x.ToList();
        }
        private void uRemoveButton_Click(object sender, EventArgs e)
        {
            if (uUserIDTextBox.Text == "")
            {
                MessageBox.Show("please enter User ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Customer c = scdc.Customers.SingleOrDefault(x => x.C_ID == int.Parse(uUserIDTextBox.Text));

                scdc.Customers.DeleteOnSubmit(c);
                scdc.SubmitChanges();
                UserlistGridViewUpdate();
                uUserIDTextBox.Text = string.Empty;
            }
        }
        private void DeleteFromList_Click(object sender, EventArgs e)
        {
            if (productIDTextBox.Text == "")
            {
                MessageBox.Show("enter a valid PRODUCT ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Transaction p = scdc.Transactions.SingleOrDefault(x => x.P_ID == int.Parse(productIDTextBox.Text));

                scdc.Transactions.DeleteOnSubmit(p);
                scdc.SubmitChanges();
                LoadShoppinList();
                productNameTextBox.Text = productIDTextBox.Text = priceTextBox.Text = quantityTextBox.Text = string.Empty;
            }
        }
        private void deleteProduct_Click(object sender, EventArgs e)
        {
            if (productidTextBox.Text == "")
            {
                MessageBox.Show("Please Insert Valid PRODUCT ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Product p = scdc.Products.SingleOrDefault(x => x.P_ID == int.Parse(productidTextBox.Text));

                scdc.Products.DeleteOnSubmit(p);
                scdc.SubmitChanges();
                productListGridViewUpdate();
                productidTextBox.Text = string.Empty;
                MessageBox.Show("PRODUCT HAS BEEN DELETED");
            }
        }
        private void deleteCatButton_Click(object sender, EventArgs e)
        {
            if (catDesTextBox.Text == "")
            {
                MessageBox.Show("Please enter valid CATEGORY ID");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Category cat = scdc.Categories.SingleOrDefault(x => x.Cat_ID == int.Parse(catIDTextBox.Text));

                scdc.Categories.DeleteOnSubmit(cat);

                scdc.SubmitChanges();
                categorylistGridViewUpdate();
                catIDTextBox.Text = string.Empty;
            }
        }
        void productListGridViewUpdate()
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            var s = from a in scdc.Products
                    from b in scdc.Categories
                    where a.Cat_ID == b.Cat_ID
                    select new
            {
                Product_Name  = a.P_Name,
                Product_ID    = a.P_ID,
                Price         = a.P_Price,
                Stock         = a.P_Stock,
                CategoryID    = b.Cat_ID,
                Category_Name = b.Cat_Name
            };

            productDatagridView.DataSource = s.ToList();
        }
        public void LoadShoppinList()
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            var s = from a in scdc.Transactions

                    select new
            {
                Product_ID   = a.P_ID,
                Product_Name = a.P_Name,

                Price  = a.Price,
                Amount = a.Quantity,

                Total = a.Total
            };

            shoppingListDataGridview.DataSource = s.ToList();
        }
        private void showAll_Click(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            String s1 = categoryComboBox.Text;

            if (s1 == "")
            {
                var x = from a in scdc.Products
                        from b in scdc.Categories
                        where a.Cat_ID == b.Cat_ID
                        select new
                {
                    Product_Name  = a.P_Name,
                    Product_ID    = a.P_ID,
                    Price         = a.P_Price,
                    Stock         = a.P_Stock,
                    CategoryID    = b.Cat_ID,
                    Category_Name = b.Cat_Name
                };

                productGridView.DataSource = x.ToList();
            }
            else
            {
                var s = from b in scdc.Products
                        join a in scdc.Categories on b.Cat_ID equals a.Cat_ID
                        where a.Cat_Name == s1
                        select new
                {
                    Product_Name  = b.P_Name,
                    Product_ID    = b.P_ID,
                    Price         = b.P_Price,
                    Stock         = b.P_Stock,
                    CategoryID    = b.Cat_ID,
                    Category_Name = a.Cat_Name
                };
                productGridView.DataSource = s.ToList();
            }
            categoryComboBox.Text = string.Empty;
        }
 private void insertCatButton_Click(object sender, EventArgs e)
 {
     if (catNameTextBox.Text == "" || catDesTextBox.Text == "")
     {
         MessageBox.Show("Fill up all the textbox except Category ID");
     }
     else
     {
         ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");
         Category cat = new Category
         {
             //Cat_ID = Convert.ToInt32(catIDTextBox.Text),
             Cat_Name = catNameTextBox.Text,
             Cat_Des  = catDesTextBox.Text
         };
         scdc.Categories.InsertOnSubmit(cat);
         scdc.SubmitChanges();
         categorylistGridViewUpdate();
         catIDTextBox.Text = catNameTextBox.Text = catDesTextBox.Text = string.Empty;
     }
 }
        private void updateCatButton_Click(object sender, EventArgs e)
        {
            if (catDesTextBox.Text == "" || catNameTextBox.Text == "" || catDesTextBox.Text == "")
            {
                MessageBox.Show("please fill up all the informations");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Category cat = scdc.Categories.SingleOrDefault(x => x.Cat_ID == int.Parse(catIDTextBox.Text));

                cat.Cat_Name = catNameTextBox.Text;
                cat.Cat_Des  = catDesTextBox.Text;

                scdc.SubmitChanges();

                catNameTextBox.Text = catIDTextBox.Text = catDesTextBox.Text = string.Empty;
                categorylistGridViewUpdate();
            }
        }
        private void updateButton_Click(object sender, EventArgs e)
        {
            if (productNameTextBox.Text == "" || productdesTextbox.Text == "" || productPriceTextBox.Text == "" || stockTextBox.Text == "" || categoryComboBox.Text == "" || productidTextBox.Text == "")
            {
                MessageBox.Show("please fill up all information Correctly");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

                Product p = scdc.Products.SingleOrDefault(x => x.P_ID == int.Parse(productidTextBox.Text));

                p.P_Name  = productNameTextBox.Text;
                p.P_Price = Convert.ToDouble(productPriceTextBox.Text);
                p.P_Stock = int.Parse(stockTextBox.Text);
                p.P_Des   = productdesTextbox.Text;
                p.Cat_ID  = int.Parse(categoryComboBox.Text);

                scdc.SubmitChanges();
                productListGridViewUpdate();
                productNameTextBox.Text = productidTextBox.Text = productPriceTextBox.Text = productdesTextbox.Text = stockTextBox.Text = categoryComboBox.Text = string.Empty;
                MessageBox.Show("PRODUCT UPDATED SUCCESSFULLY");
            }
        }
        private void Shopping_List_Load(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            Customer u2 = scdc.Customers.SingleOrDefault(x => x.C_ID == pp.id);

            CF_name.Text = u2.C_Firstname;
            CLname.Text  = u2.C_Lastname;
            var s = from a in scdc.Transactions

                    select new
            {
                Product_ID   = a.P_ID,
                Product_Name = a.P_Name,

                Price  = a.Price,
                Amount = a.Quantity,

                Total = a.Total
            };

            Final_ListGridView.DataSource = s.ToList();

            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            con.Open();
            SqlCommand query = new SqlCommand("select sum(Total) from [Transaction]");

            query.Connection = con;
            decimal sum = Convert.ToDecimal(query.ExecuteScalar());

            regualTotalLabel.Text = Convert.ToString(sum);

            totalVatLabel.Text   = "0.00";
            finalTotalLabel.Text = Convert.ToString(sum);
        }
        private void aEditButton_Click(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            Admin c = scdc.Admins.SingleOrDefault(x => x.A_ID == int.Parse(aUserIDTextBox.Text));

            c.A_Firstname = aFirstnameTextBox.Text;
            c.A_Lastname  = aLastnameTextBox.Text;
            c.A_Email     = aEmailTextBox.Text;
            c.A_Password  = Convert.ToInt32(aPasswordTextBox.Text);
            c.A_Phone     = aPhoneTextBox.Text;
            c.A_Address   = aAddressTextBox.Text;

            scdc.SubmitChanges();


            fnameLabel.Text    = c.A_Firstname;
            lnamelabel.Text    = c.A_Lastname;
            emaillabel.Text    = c.A_Email;
            phonelabel.Text    = c.A_Phone;
            addresslabel.Text  = c.A_Address;
            idlabel.Text       = Convert.ToString(c.A_ID);
            passwordlabel.Text = Convert.ToString(c.A_Password);
        }
        private void InsertToList_Click(object sender, EventArgs e)
        {
            if (productIDTextBox.Text == "" || productNameTextBox.Text == "" || priceTextBox.Text == "" || quantityTextBox.Text == "")
            {
                MessageBox.Show("Please add quantity to product");
            }
            else
            {
                ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");
                Transaction             t    = new Transaction();
                t.P_ID     = Convert.ToInt32(productIDTextBox.Text);
                t.P_Name   = productNameTextBox.Text;
                t.Price    = int.Parse(priceTextBox.Text);
                t.Quantity = int.Parse(quantityTextBox.Text);
                t.Total    = (int.Parse(quantityTextBox.Text)) * (int.Parse(priceTextBox.Text));

                scdc.Transactions.InsertOnSubmit(t);
                scdc.SubmitChanges();

                LoadShoppinList();

                productIDTextBox.Text = productNameTextBox.Text = priceTextBox.Text = quantityTextBox.Text = string.Empty;
            }
        }
        void UserlistGridViewUpdate()
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");

            userlistDataGridView.DataSource = scdc.Customers;
        }
        /* private void ConfirmList_Click_1(object sender, EventArgs e)
         * {
         *   ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");
         *
         *
         *   //Console.WriteLine(sum);
         *
         *
         *
         * }*/

        private void categoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ShoppingCartDataContext scdc = new ShoppingCartDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Project\MainFrame\MainFrame\ShoppinCart.mdf;Integrated Security=True;Connect Timeout=30");
            int      id  = int.Parse(categoryComboBox.SelectedValue.ToString());
            Category cat = scdc.Categories.SingleOrDefault(x => x.Cat_ID == id);
        }