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); //} }