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);
        }
Beispiel #2
0
        private void DeliveryBoys_usercontrol_Load(object sender, EventArgs e)
        {
            DeliveryBoy best = xml.BestDeliveryBoy_AllAreas();

            lbl_dbID.Text     = best.id;
            lbl_dbName.Text   = best.name;
            lbl_dbPhone.Text  = best.phone;
            lbl_dbArea.Text   = best.area;
            lbl_dbOrders.Text = best.NumberofOrders.ToString();
        }
        public DeliveryBoy order(string area)
        {
            List <DeliveryBoy> list = GetDeliveryBoysinArea(area);

            Random random = new Random();
            int    r      = random.Next(list.Count);

            DeliveryBoy db = list[r];

            //    MessageBox.Show(db.name + "  elly hywasl el order");
            db.NumberofOrders++;
            string orders = db.NumberofOrders.ToString();

            XmlDocument doc = new XmlDocument();

            string path = Path.Combine(Application.StartupPath, @"C:\Users\lenovo\Documents\Visual Studio 2013\Projects\RestaurantProject\RestaurantProject\bin\Debug\DeliveryBoy.xml");

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

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

                string id       = childerns[0].Name;
                string idvaluue = 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 (idvaluue.Equals(db.id) && namevalue.Equals(db.name) && phonevalue.Equals(db.phone))
                {
                    XmlElement root = doc.DocumentElement;


                    childerns[4].InnerText = orders;

                    doc.Save("DeliveryBoy.xml");
                    break;
                }
            }
            //     MessageBox.Show("done");
            return(db);
        }
Beispiel #4
0
        private void cmb_Area_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            String             area = cmb_Area.SelectedItem.ToString();
            List <DeliveryBoy> list = xml.GetDeliveryBoysinArea(area);

            for (int i = 0; i < list.Count; i++)
            {
                DeliveryBoy a = list[i];
                dataGridView1.Rows.Add(new string[] { a.id, a.name, a.phone, a.area, a.NumberofOrders.ToString() });
            }
            MessageBox.Show("Best Delivery Boy --> " + xml.BestDeliveryBoy(area).name);
        }
        public DeliveryBoy BestDeliveryBoy(String area)
        {
            List <DeliveryBoy> list = GetDeliveryBoysinArea(area);

            DeliveryBoy bestdeliveryboy = null;
            int         orders          = -1;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].NumberofOrders > orders)
                {
                    orders          = list[i].NumberofOrders;
                    bestdeliveryboy = list[i];
                }
            }
            return(bestdeliveryboy);
        }
        public DeliveryBoy BestDeliveryBoy_AllAreas()
        {
            DeliveryBoy BestDeliveryBoy = null;
            int         count           = 0;
            XmlDocument doc             = new XmlDocument();
            string      path            = Path.Combine(Application.StartupPath, @"C:\Users\lenovo\Documents\Visual Studio 2013\Projects\RestaurantProject\RestaurantProject\bin\Debug\DeliveryBoy.xml");

            doc.Load("DeliveryBoy.xml");
            XmlNodeList        list         = doc.GetElementsByTagName("DeliveryBoy");
            List <DeliveryBoy> deliveryboys = new List <DeliveryBoy>();

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

                string id       = childerns[0].Name;
                string idvaluue = 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;
                int    NumberOfOrders = int.Parse(nuvalue);
                if (NumberOfOrders > count)
                {
                    BestDeliveryBoy = new DeliveryBoy(idvaluue, namevalue, phonevalue, areacodevalue, nuvalue);
                    count           = NumberOfOrders;
                }
            }

            return(BestDeliveryBoy);
        }
        public List <DeliveryBoy> GetDeliveryBoysinArea(String area)
        {
            DeliveryBoy d = new DeliveryBoy();

            XmlDocument doc  = new XmlDocument();
            string      path = Path.Combine(Application.StartupPath, @"C:\Users\lenovo\Documents\Visual Studio 2013\Projects\RestaurantProject\RestaurantProject\bin\Debug\DeliveryBoy.xml");

            doc.Load("DeliveryBoy.xml");
            XmlNodeList        list         = doc.GetElementsByTagName("DeliveryBoy");
            List <DeliveryBoy> deliveryboys = new List <DeliveryBoy>();

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

                string id       = childerns[0].Name;
                string idvaluue = 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 (areacodevalue.Equals(area))
                {
                    d = new DeliveryBoy(idvaluue, namevalue, phonevalue, areacodevalue, nuvalue);
                    deliveryboys.Add(d);
                }
            }
            return(deliveryboys);
        }
Beispiel #8
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";
        }
        public InoviceForm(string price, string discount, List <DataGridViewRow> list, DeliveryBoy boy)
        {
            InitializeComponent();
            lblDate.Text = DateTime.Now.ToLongDateString();
            if (Main_Menu.premium)
            {
                lblCustInf.Text = "Bill to :  0" + Main_Menu.CustomerPhone.ToString() + Environment.NewLine + "Premium Customer  " + Environment.NewLine + "  discount" + Main_Menu.Discount_Percent + " %";
            }
            else
            {
                lblCustInf.Text = "Bill to :  0" + Main_Menu.CustomerPhone.ToString() + Environment.NewLine;
            }

            lblShip.Text = "Ship To: " + Environment.NewLine + Main_Menu.Full_Address + Environment.NewLine + "Deliver Boy :" + boy.name + Environment.NewLine + "DB Phone: " + boy.phone;
            foreach (DataGridViewRow r in list)
            {
                ListViewItem l_item = new ListViewItem();

                l_item.Text = r.Cells[0].Value.ToString();
                l_item.SubItems.Add(r.Cells[1].Value.ToString());
                l_item.SubItems.Add(r.Cells[2].Value.ToString());
                l_item.SubItems.Add(r.Cells[3].Value.ToString());
                l_item.SubItems.Add(r.Cells[4].Value.ToString());
                //   l_item.SubItems.Add(r.Cells["Total Price"].Value.ToString());

                listView1.Items.Add(l_item);
            }

            lbl_Total.Text = price + "$";
        }