コード例 #1
0
        //What the Client can use
        public void AddToCart(object sender, EventArgs e)
        {
            try
            {
                TheClasses.ProdTshirts objTshirt = new TheClasses.ProdTshirts();
                int    optionclick;
                Button sendingBox = (Button)sender;

                switch (sendingBox.Name)
                {
                case "Tshirt1Button":
                    optionclick             = 1;
                    objTshirt.NameTshirt1   = Tshirt1Label.Text;
                    objTshirt.PriceTshirts1 = Convert.ToInt32(Price1Label.Text.Remove(2));

                    if (objTshirt.NumberCheck(Tshirt1TextBox.Text) == true)
                    {
                        Tshirt1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objTshirt.CountPriceAndItems(Convert.ToInt32(Tshirt1TextBox.Text), optionclick);
                    label1.Text = objTshirt.UpdatePrice(label1.Text);
                    label2.Text = objTshirt.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Tshirt1TextBox.Clear();

                    break;

                case "Tshirt2Button":
                    optionclick             = 2;
                    objTshirt.NameTshirt2   = Tshirt2Label.Text;
                    objTshirt.PriceTshirts2 = Convert.ToInt32(Price2Label.Text.Remove(2));

                    if (objTshirt.NumberCheck(Tshirt2TextBox.Text) == true)
                    {
                        Tshirt2TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objTshirt.CountPriceAndItems(Convert.ToInt32(Tshirt2TextBox.Text), optionclick);
                    label1.Text = objTshirt.UpdatePrice(label1.Text);
                    label2.Text = objTshirt.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Tshirt2TextBox.Clear();
                    break;

                case "Tshirt3Button":
                    optionclick             = 3;
                    objTshirt.NameTshirt3   = Tshirt3Label.Text;
                    objTshirt.PriceTshirts3 = Convert.ToInt32(Price3Label.Text.Remove(2));

                    if (objTshirt.NumberCheck(Tshirt3TextBox.Text) == true)
                    {
                        Tshirt3TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objTshirt.CountPriceAndItems(Convert.ToInt32(Tshirt3TextBox.Text), optionclick);
                    label1.Text = objTshirt.UpdatePrice(label1.Text);
                    label2.Text = objTshirt.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Tshirt3TextBox.Clear();
                    break;

                case "Tshirt4Button":
                    optionclick             = 4;
                    objTshirt.NameTshirt4   = Tshirt4Label.Text;
                    objTshirt.PriceTshirts4 = Convert.ToInt32(Price4Label.Text.Remove(2));

                    if (objTshirt.NumberCheck(Tshirt4TextBox.Text) == true)
                    {
                        Tshirt4TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objTshirt.CountPriceAndItems(Convert.ToInt32(Tshirt4TextBox.Text), optionclick);
                    label1.Text = objTshirt.UpdatePrice(label1.Text);
                    label2.Text = objTshirt.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Tshirt4TextBox.Clear();
                    break;

                case "RecycleButton":
                    //objTshirt.TotalTshirts1 = 0;
                    //objTshirt.TotalTshirts2 = 0;
                    //objTshirt.TotalTshirts3 = 0;
                    //objTshirt.TotalTshirts4 = 0;
                    //objTshirt.TotalOfItems = 0;
                    //objTshirt.TotalOfPrice = 0;
                    objTshirt.RecicleItemsPrice();
                    label1.Text = objTshirt.UpdatePrice(label1.Text);
                    label2.Text = objTshirt.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    break;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #2
0
        //What the Client can use
        public void AddToCart(object sender, EventArgs e)
        {
            try
            {
                TheClasses.ProdJeans objJeans = new TheClasses.ProdJeans();
                int    optionclick;
                Button sendingBox = (Button)sender;

                switch (sendingBox.Name)
                {
                case "Jeans1Button":
                    optionclick          = 1;
                    objJeans.NameJeans1  = Convert.ToString(Jeans1Label.Text);
                    objJeans.PriceJeans1 = Convert.ToInt32(Price1Label.Text.Remove(2));

                    if (objJeans.NumberCheck(Jeans1TextBox.Text) == true)
                    {
                        Jeans1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objJeans.CountPriceAndItems(Convert.ToInt32(Jeans1TextBox.Text), optionclick);
                    label1.Text = objJeans.UpdatePrice(label1.Text);
                    label2.Text = objJeans.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jeans1TextBox.Clear();
                    break;

                case "Jeans2Button":
                    optionclick          = 2;
                    objJeans.NameJeans2  = Convert.ToString(Jeans2Label.Text);
                    objJeans.PriceJeans2 = Convert.ToInt32(Price2Label.Text.Remove(2));

                    if (objJeans.NumberCheck(Jeans2TextBox.Text) == true)
                    {
                        Jeans2TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objJeans.CountPriceAndItems(Convert.ToInt32(Jeans2TextBox.Text), optionclick);
                    label1.Text = objJeans.UpdatePrice(label1.Text);
                    label2.Text = objJeans.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jeans2TextBox.Clear();
                    break;

                case "Jeans3Button":
                    optionclick          = 3;
                    objJeans.NameJeans3  = Convert.ToString(Jeans3Label.Text);
                    objJeans.PriceJeans3 = Convert.ToInt32(Price3Label.Text.Remove(2));

                    if (objJeans.NumberCheck(Jeans3TextBox.Text) == true)
                    {
                        Jeans3TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objJeans.CountPriceAndItems(Convert.ToInt32(Jeans3TextBox.Text), optionclick);
                    label1.Text = objJeans.UpdatePrice(label1.Text);
                    label2.Text = objJeans.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jeans3TextBox.Clear();
                    break;

                case "Jeans4Button":
                    optionclick          = 4;
                    objJeans.NameJeans4  = Convert.ToString(Jeans4Label.Text);
                    objJeans.PriceJeans4 = Convert.ToInt32(Price4Label.Text.Remove(2));

                    if (objJeans.NumberCheck(Jeans4TextBox.Text) == true)
                    {
                        Jeans4TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objJeans.CountPriceAndItems(Convert.ToInt32(Jeans4TextBox.Text), optionclick);
                    label1.Text = objJeans.UpdatePrice(label1.Text);
                    label2.Text = objJeans.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jeans4TextBox.Clear();
                    break;

                case "Jeans5Button":
                    optionclick          = 5;
                    objJeans.NameJeans5  = Convert.ToString(Jeans5Label.Text);
                    objJeans.PriceJeans5 = Convert.ToInt32(Price5Label.Text.Remove(2));

                    if (objJeans.NumberCheck(Jeans5TextBox.Text) == true)
                    {
                        Jeans5TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objJeans.CountPriceAndItems(Convert.ToInt32(Jeans5TextBox.Text), optionclick);
                    label1.Text = objJeans.UpdatePrice(label1.Text);
                    label2.Text = objJeans.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jeans5TextBox.Clear();
                    break;

                case "RecycleButton":
                    //objJeans.TotalJeans1 = 0;
                    //objJeans.TotalJeans2 = 0;
                    //objJeans.TotalJeans3 = 0;
                    //objJeans.TotalJeans4 = 0;
                    //objJeans.TotalJeans5 = 0;
                    //objJeans.TotalOfItems = 0;
                    //objJeans.TotalOfPrice = 0;
                    objJeans.RecicleItemsPrice();
                    label1.Text = objJeans.UpdatePrice(label1.Text);
                    label2.Text = objJeans.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    break;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #3
0
        //What the Client can use
        private void ClientUsage(object sender, EventArgs e)
        {
            try
            {
                TheClasses.ProdAccessories objAccessory = new TheClasses.ProdAccessories();
                int    optionclick;
                Button sendingButton = (Button)sender;

                switch (sendingButton.Name)
                {
                case "Bag1Button":
                    optionclick = 1;
                    objAccessory.NameAccessory1  = Bag1Label.Text;
                    objAccessory.PriceAccessory1 = Convert.ToInt32(Price1Label.Text.Remove(2));

                    if (objAccessory.NumberCheck(Bag1TextBox.Text) == true)
                    {
                        Bag1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objAccessory.CountPriceAndItems(Convert.ToInt32(Bag1TextBox.Text), optionclick);
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Bag1TextBox.Clear();
                    break;

                case "Bag2Button":
                    optionclick = 2;
                    objAccessory.NameAccessory2  = Bag2Label.Text;
                    objAccessory.PriceAccessory2 = Convert.ToInt32(Price2Label.Text.Remove(2));

                    if (objAccessory.NumberCheck(Bag2TextBox.Text) == true)
                    {
                        Bag1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objAccessory.CountPriceAndItems(Convert.ToInt32(Bag2TextBox.Text), optionclick);
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Bag2TextBox.Clear();
                    break;

                case "Jewelry1Button":

                    optionclick = 3;
                    objAccessory.NameAccessory3  = Jewelry1Label.Text;
                    objAccessory.PriceAccessory3 = Convert.ToInt32(Price3Label.Text.Remove(2));

                    if (objAccessory.NumberCheck(Jewelry1TextBox.Text) == true)
                    {
                        Bag1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objAccessory.CountPriceAndItems(Convert.ToInt32(Jewelry1TextBox.Text), optionclick);
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jewelry1TextBox.Clear();
                    break;

                case "Jewelry2Button":
                    optionclick = 4;
                    objAccessory.NameAccessory4  = Jewelry2Label.Text;
                    objAccessory.PriceAccessory4 = Convert.ToInt32(Price4Label.Text.Remove(2));

                    if (objAccessory.NumberCheck(Jewelry2TextBox.Text) == true)
                    {
                        Bag1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objAccessory.CountPriceAndItems(Convert.ToInt32(Jewelry2TextBox.Text), optionclick);
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    Jewelry2TextBox.Clear();
                    break;

                case "WalletButton":
                    optionclick = 5;
                    objAccessory.NameAccessory5  = WalletLabel.Text;
                    objAccessory.PriceAccessory5 = Convert.ToInt32(Price5Label.Text.Remove(2));

                    if (objAccessory.NumberCheck(WalletTextBox.Text) == true)
                    {
                        Bag1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objAccessory.CountPriceAndItems(Convert.ToInt32(WalletTextBox.Text), optionclick);
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    WalletTextBox.Clear();
                    break;

                case "HatButton":
                    optionclick = 6;
                    objAccessory.NameAccessory6  = HatLabel.Text;
                    objAccessory.PriceAccessory6 = Convert.ToInt32(Price6Label.Text.Remove(2));

                    if (objAccessory.NumberCheck(HatTextBox.Text) == true)
                    {
                        Bag1TextBox.Clear();
                        throw new Exception("Please insert a correct amount!");
                    }

                    objAccessory.CountPriceAndItems(Convert.ToInt32(HatTextBox.Text), optionclick);
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    HatTextBox.Clear();
                    break;

                case "RecycleButton":
                    objAccessory.RecicleItemsPrice();
                    label1.Text = objAccessory.UpdatePrice(label1.Text);
                    label2.Text = objAccessory.UpdateItems(label2.Text);
                    originalForm.cart(label1.Text, label2.Text);
                    break;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #4
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            try
            {
                bool x = true;
                TheClasses.NewOrder objNewOrder = new TheClasses.NewOrder();
                TextInfo            textInfo    = new CultureInfo("en-US", false).TextInfo;

                #region Address

                //objNewOrder.NullCheck(Address);
                //Address.Text = Address.Text.ToLower();
                //objNewOrder.UnicodeCheck(Address, 4);


                if (objNewOrder.NullCheck(Address.Text) == false)
                {
                    Address.Clear();
                    throw new Exception("Please insert your '" + Address.Name + "' !");
                }

                if (objNewOrder.UnicodeCheck(Address.Text, 4) == false)
                {
                    Address.Clear();
                    throw new Exception("Please insert a correct '" + Address.Name + "' !");
                }

                objNewOrder.Address += textInfo.ToTitleCase(Address.Text);

                #endregion

                #region City

                //objNewOrder.NullCheck(City);
                //City.Text = City.Text.ToLower();
                //objNewOrder.UnicodeCheck(City, 1);

                if (objNewOrder.NullCheck(City.Text) == false)
                {
                    City.Clear();
                    throw new Exception("Please insert your '" + City.Name + "' !");
                }

                if (objNewOrder.UnicodeCheck(City.Text, 1) == false)
                {
                    City.Clear();
                    throw new Exception("Please insert a correct '" + City.Name + "' !");
                }

                objNewOrder.City += textInfo.ToTitleCase(City.Text);

                #endregion

                #region Region

                if (objNewOrder.NullCheck(Regionn.Text) == false)
                {
                    Regionn.Clear();
                    throw new Exception("Please insert your '" + Regionn.Name + "' !");
                }

                if (objNewOrder.UnicodeCheck(City.Text, 1) == false)
                {
                    Regionn.Clear();
                    throw new Exception("Please insert a correct '" + Regionn.Name + "' !");
                }

                objNewOrder.Region += textInfo.ToTitleCase(Regionn.Text);

                #endregion

                //Country

                #region PostalCode

                if (string.IsNullOrEmpty(PostalCode.Text))
                {
                    x = false;
                }
                if (x == true)
                {
                    if (objNewOrder.LetterCheck(PostalCode.Text) == false)
                    {
                        PostalCode.Clear();
                        throw new Exception("Please insert a correct '" + PostalCode.Name + "' !");
                    }

                    if (objNewOrder.UnicodeCheck(PostalCode.Text, 0) == false)
                    {
                        PostalCode.Clear();
                        throw new Exception("Please insert a correct '" + PostalCode.Name + "' !");
                    }
                }

                objNewOrder.PostalCode += PostalCode.Text;

                #endregion

                #region Fax

                if (string.IsNullOrEmpty(Fax.Text))
                {
                    x = false;
                }
                if (x == true)
                {
                    if (objNewOrder.LetterCheck(Fax.Text) == false)
                    {
                        Fax.Clear();
                        throw new Exception("Please insert a correct '" + Fax.Name + "' !");
                    }

                    if (objNewOrder.UnicodeCheck(Fax.Text, 0) == false)
                    {
                        Fax.Clear();
                        throw new Exception("Please insert a correct '" + Fax.Name + "' !");
                    }
                }

                objNewOrder.Fax += Fax.Text;

                #endregion

                //Ship via
                if (Country.SelectedItem != null && ShipVia.SelectedItem != null)
                {
                    objNewOrder.Country += (string)Country.SelectedItem;
                    objNewOrder.ShipVia += (string)ShipVia.SelectedItem;

                    //SQL Command
                    string _command = "INSERT INTO Customer.dbo.Orders (Address,City,Region,Country,PostalCode,Fax,ShipVia,TotalItems,TotalPrice,CustomerId) VALUES('"
                                      + objNewOrder.Address + "','"
                                      + objNewOrder.City + "','"
                                      + objNewOrder.Region + "','"
                                      + objNewOrder.Country + "','"
                                      + objNewOrder.PostalCode + "','"
                                      + objNewOrder.Fax + "','"
                                      + objNewOrder.ShipVia + "','"
                                      + TheClasses.EntityProducts._totalofitems + "','"
                                      + TheClasses.EntityProducts._totalofprice + "','"
                                      + LoginDesign.CustomerIdCheck + "')";

                    objNewOrder.InsertReadUpdateData(_command);
                    MessageBox.Show("You have succesfuly placed an order!");
                    this.Close();
                    TheClasses.EntityProducts._totalofitems = 0;
                    TheClasses.EntityProducts._totalofprice = 0;
                    originalForm.cart(TheClasses.EntityProducts._totalofitems.ToString() + " $", TheClasses.EntityProducts._totalofprice.ToString() + " Items");
                }
                else if (Country.SelectedItem == null)
                {
                    MessageBox.Show("Please select a " + Country.Text + "!");
                }
                else if (ShipVia.SelectedItem == null)
                {
                    MessageBox.Show("Please select a " + ShipVia.Text + " method!");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }