public DeliveryBoy order2(string area)
        {
            DeliveryBoyxml d   = new DeliveryBoyxml();
            List <string>  IDs = d.GetDeliveryBoys_DELIVERY(area);

            Random random = new Random();
            int    r      = random.Next(IDs.Count);
            string id     = IDs[r];

            List <DeliveryBoy> list_deliveryBoys = d.GetDeliveryBoysinArea(area);

            for (int i = 0; i < list_deliveryBoys.Count; i++)
            {
                DeliveryBoy db = list_deliveryBoys[i];
                if (db.id == id)
                {
                    int         orders = db.NumberofOrders + 1;
                    XmlDocument doc    = new XmlDocument();

                    doc.Load("DeliveryBoy.xml");

                    XmlNodeList list2 = doc.GetElementsByTagName("DeliveryBoy");

                    for (int j = 0; j < list2.Count; j++)
                    {
                        XmlNodeList childerns = list2[i].ChildNodes;

                        string idd       = childerns[0].Name;
                        string iddvaluue = childerns[0].InnerText;

                        string name      = childerns[1].Name;
                        string namevalue = childerns[1].InnerText;;

                        string phone      = childerns[2].Name;
                        string phonevalue = childerns[2].InnerText;;

                        string AreaCode      = childerns[3].Name;
                        string areacodevalue = childerns[3].InnerText;

                        string numberodorders = childerns[4].Name;
                        string nuvalue        = childerns[4].InnerText;

                        if (iddvaluue.Equals(db.id) && namevalue.Equals(db.name) && phonevalue.Equals(db.phone))
                        {
                            XmlElement root = doc.DocumentElement;

                            childerns[4].InnerText = orders.ToString();

                            doc.Save("DeliveryBoy.xml");
                            break;
                        }
                    }
                    return(db);
                }
            }
            return(null);
        }
Пример #2
0
        private void btn_Order_Click(object sender, EventArgs e)
        {
            if ((txt_Phone.Text == "Phone Number") && cmb_Area.SelectedIndex == -1)
            {
                MessageBox.Show("please Enter your Details to checkout your order ");
            }
            else
            {
                ConfirmCustomerOrder();
            }

            DeliveryBoyxml     xml = new DeliveryBoyxml();
            List <DeliveryBoy> deliveryBoysList = xml.GetDeliveryBoysinArea(area);

            DeliveryBoy Orderdb = xml.order2(area);

            lbl_dbID.Text    = Orderdb.id;
            lbl_dbName.Text  = Orderdb.name;
            lbl_dbPhone.Text = Orderdb.phone;

            pnl_db.Visible = true;
            MessageBox.Show("Checked out successfully");

            for (int i = 0; i < Grd_Cart.Rows.Count; i++)
            {
                int    id        = Convert.ToInt32(Grd_Cart.Rows[i].Cells[0].Value);
                string food_Name = Grd_Cart.Rows[i].Cells[1].Value.ToString();
                int    purchased = Convert.ToInt32(Grd_Cart.Rows[i].Cells[2].Value);

                MenuArray.menuLst[id - 1].sold += purchased;
                Sold_in_Areas.update_Sold_In_Area(area, food_Name, purchased);
            }


            List <DataGridViewRow> cartItems = new List <DataGridViewRow>();

            foreach (DataGridViewRow item in Grd_Cart.Rows)
            {
                DataGridViewRow r = (DataGridViewRow)item.Clone();

                for (int i = 0; i < item.Cells.Count; i++)
                {
                    r.Cells[i].Value = item.Cells[i].Value;
                }
                cartItems.Add(r);
            }



            InoviceForm f = new InoviceForm(lbl_Finalprice.Text, lbl_discount.Text, cartItems, Orderdb);

            f.Show();
            serializeData();
            DeserializeMenu();
            chartuser.BoysChartRefresher();
            AddRecommendedMeals();
            pervious(CustomerPhone);


            Grd_Cart.Rows.Clear();
            total               = 0;
            lbl_Total.Text      = "0";
            lbl_Finalprice.Text = "0";
        }