Exemple #1
0
        private void btnPlaceOrder_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("Enetr Name");
            }
            if (string.IsNullOrEmpty(txtCNIC.Text))
            {
                MessageBox.Show("Enter your CNIC");
            }

            if (string.IsNullOrEmpty(txtAddress.Text))
            {
                MessageBox.Show("Enter postal address");
            }
            if (!chkYes.Checked)
            {
                MessageBox.Show("Approve your status");
            }
            else
            {
                localhost.Order order = new localhost.Order();
                order.Name   = txtUsername.Text;
                order.Adress = txtAddress.Text;
                order.Shoe   = MyUtils.curr_shoe;
                localhost.Service1 ns = new localhost.Service1();
                ns.PlaceOrder(order);

                MessageBox.Show("Your order has been placed");
            }
        }
    protected void btnOrder_Click(object sender, EventArgs e)
    {
        // Response.Write(Functions.AlertBox(dtClient.Rows[0][0].ToString()));
        //Add the credit card
        localhost.CreditCard card = new localhost.CreditCard();


        card.Username = dtClient.Rows[0][0].ToString();
        card.Code     = txtCode.Text;

        card.ExpiryDate = dropMonth.SelectedValue + "/" + dropYear.SelectedValue;

        card.Cvv = int.Parse(txtCvv.Text);


        if (!s.SearchCardCode(txtCode.Text))
        {
            s.AddCreditCard(card);
        }

        //******************************************************


        //Add the order products

        localhost.Order order = new localhost.Order();

        string generate = Functions.generateID();

        while (s.SearchOrderId(generate))
        {
            generate = Functions.generateID();
        }

        order.Id = generate;

        order.Username = dtClient.Rows[0][0].ToString();

        order.Date = DateTime.Now.ToString("dd/MM/yyyy");

        order.Total = GetTotal();

        order.Status = 1;
        s.AddOrder(order);
        //Add the order details
        string idProduct = "";
        //localhost.OrderDetails details = new localhost.OrderDetails();
        //for (int i = 0; i < GrdOrder.Rows.Count; i++)
        //{
        //    idProduct = s.SearchProducts(2, GrdOrder.Rows[i].Cells[0].Text,"All types","All Providers", "On the store").Rows[0][0].ToString();
        //    details.IdOrder = generate;

        //    details.IdProduct = idProduct;

        //    details.Price = int.Parse(GrdOrder.Rows[i].Cells[2].Text) / int.Parse(GrdOrder.Rows[i].Cells[1].Text);

        //    details.Quantity = int.Parse(GrdOrder.Rows[i].Cells[1].Text);


        //    s.AddOrderDetails(details);

        //}
    }