Beispiel #1
0
        //public int a { get; set; }

        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            if (NameTb.Text != "" && PhoneNumberTb.Text != "" && seatlist.Count != 0)
            {
                Bus b = new Bus();
                b = br.GetBus(tablebusid, tablebusname, tabledate, tabletime, tableavailableseats, tablefare);

                Customer c = new Customer();

                c.Name = NameTb.Text;
                try
                {
                    int phn = Convert.ToInt32(PhoneNumberTb.Text);
                    c.PhoneNumber = phn + "";
                }
                catch (Exception exp)
                {
                    MessageBox.Show("invalid phone number");
                }

                c.From  = b.From;
                c.To    = b.To;
                c.BusId = b.BusId;
                c.Date  = b.Date;
                c.Time  = b.Time;
                c.Type  = b.Type;
                c.Fare  = b.Fare * count;
                foreach (string item in seatlist)
                {
                    s = s + item + ",";
                }
                c.SeatNumber = s;

                if (cr.InsertCustomer(c))
                {
                    MessageBox.Show("seat booked. THANK YOU!");
                }
                else
                {
                    MessageBox.Show("Can Not Book: " + c.Name);
                }
                for (int i = 0; i < seatlist.Count; i++)
                {
                    br.UpdateSeat(b, seatlist[i]);
                }
                b.NumberOfSeats = b.NumberOfSeats - count;
                br.UpdateNumberSeat(b);


                PrintTicket p = new PrintTicket(c);
                p.Visible    = true;
                this.Visible = false;
            }
            else
            {
                MessageBox.Show("Please fillup Name, Phone number and Seats");
            }
        }
Beispiel #2
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            Customer cm = new Customer();

            cm.Name        = this.CustomerNameTb.Text;
            cm.PhoneNumber = this.PhoneTB.Text;
            cm.From        = tablefrom;
            cm.To          = tableto;
            cm.BusId       = tablebusid;
            cm.Date        = tabledate;
            cm.Time        = tabletime;
            cm.Type        = tabletype;
            cm.SeatNumber  = tableseatnumber;
            cm.Fare        = Convert.ToInt32(tablefare);
            string [] seatnumbers = tableseatnumber.Split(',');


            if (cr.DeleteCustomer(cm))
            {
                MessageBox.Show("Deleted");
                this.ShowAllBtn_Click(sender, e);
                int     i  = 0;
                Bus     b  = new Bus();
                BusRepo br = new BusRepo();
                while (seatnumbers[i] != "")
                {
                    b = br.GetBus(tablebusid, tabledate, tabletime);
                    br.updatefordelete(b, seatnumbers[i]);
                    i++;
                }
                MessageBox.Show(b.NumberOfSeats + " " + seatnumbers.Length);
                b.NumberOfSeats = (b.NumberOfSeats + seatnumbers.Length - 1);
                br.UpdateNumberSeat(b);
            }

            else
            {
                MessageBox.Show("Can Not Delete");
            }
        }