示例#1
0
        private void order_Click(object sender, EventArgs e)
        {
            string message = "From : " + productSeller.Text + Environment.NewLine;

            message += "To : " + UserControl.userFullname() + Environment.NewLine;
            message += "Price : " + productPrice.Text + Environment.NewLine;
            DialogResult result = MessageBox.Show(message, "Confirmation", MessageBoxButtons.YesNoCancel);

            if (result == DialogResult.Yes)
            {
                try
                {
                    using (var context = new ShopExpressEntities())
                    {
                        var product = new Product {
                            productID = productIDtemp
                        };
                        context.Products.Attach(product);
                        context.Products.Remove(product);
                        context.SaveChanges();
                    }

                    MessageBox.Show("Order confirmed!", "Confirmation");

                    userPanel.BringToFront();
                    dataSetter();
                }
                catch
                {
                    MessageBox.Show("Oops, something went wrong! Please try again!", "Error!");
                }
            }
        }
示例#2
0
        //REGISTER PANEL
        private void register_Click(object sender, EventArgs e)
        {
            using (ShopExpressEntities context = new ShopExpressEntities())
            {
                try
                {
                    context.Users.Add(new User
                    {
                        firstName = firstName.Text,
                        lastName  = lastName.Text,
                        address   = address.Text,
                        city      = city.Text,
                        country   = country.Text,
                        email     = email.Text,
                        phone     = phone.Text,
                        password  = password.Text,
                    });

                    context.SaveChanges();
                    MessageBox.Show("Success! Please login now!");
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("Oops!");//exc.Message);
                }
            }
        }
示例#3
0
        private void uploadItemButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (ShopExpressEntities context = new ShopExpressEntities())
                {
                    var catID = context.Categories
                                .Where(x => x.categoryName == itemCategory.Text)
                                .Select(x => new { x.categoryID }).ToList();

                    var colID = context.Colors
                                .Where(y => y.color == itemColor.Text)
                                .Select(y => new { y.colorID }).ToList();

                    context.Products.Add(new Product
                    {
                        categoryID         = catID[0].categoryID,
                        userID             = UserControl.ID(),
                        productName        = itemName.Text,
                        productDescription = itemDescription.Text,
                        genderCategory     = gender.Text,
                        size    = itemSize.Text,
                        colorID = colID[0].colorID,
                        price   = Convert.ToInt64(itemPrice.Text),
                        picture = picPath.Text
                    }
                                         );

                    context.SaveChanges();
                    MessageBox.Show("New item is added!");
                    userPanel.BringToFront();
                    dataSetter();
                }
            }
            catch
            {
                MessageBox.Show("Oops! Some data is invalid!");
            }
        }