コード例 #1
0
 //create a click event for the button
 private void btnBooking_Click(object sender, EventArgs e)
 {
     //using validation
     if (ValidateForm())
     {
         //if validation passess then a new booking is being created
         Bookings newBooking = new Bookings(txtNameBooking.Text, txtSurnameBooking.Text, Int32.Parse(txtPhoneBooking.Text), dateInBooking.Text, dateOutBooking.Text, txtNotesBooking.Text);
         //adding the booking to the list
         frmMain.booked.Add(newBooking);
         //creating a new instance of dashbord form and closing this
         frmMain f = new frmMain();
         f.Show();
         this.Close();
     }
 }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Form booking = new Bookings();

            booking.TopLevel        = false;
            booking.Visible         = true;
            booking.FormBorderStyle = FormBorderStyle.None;
            booking.Dock            = DockStyle.Top;

            tabPage6.Controls.Add(booking);
            getDriversActiveData();
            //Bind Staff
            try
            {
                cmd.Connection  = conn;
                cmd.CommandText = getAllStaff;
                //conn.Open();
                SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                DataTable      ds    = new DataTable();
                adapt.Fill(ds);
                dgvAllStaff.DataSource = ds;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }


            //Bind Clients
            try
            {
                cmd.Connection  = conn;
                cmd.CommandText = getAllClients;
                //conn.Open();
                SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                DataTable      ds    = new DataTable();
                adapt.Fill(ds);
                AllClientsBindingSource.DataSource = ds;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }

            //Bind Clients with bookings

            try
            {
                cmd.Connection  = conn;
                cmd.CommandText = getAllClientsWithBookings;
                //conn.Open();
                SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                DataTable      ds    = new DataTable();
                adapt.Fill(ds);
                dgvBookedClients.DataSource = ds;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }

            //Bind Vehicles
            try
            {
                cmd.Connection  = conn;
                cmd.CommandText = getAllVehicles;
                //conn.Open();
                SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                DataTable      ds    = new DataTable();
                adapt.Fill(ds);
                dgvAllVehicles.DataSource = ds;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }

            //Bind Vehicle Service Dates
            try
            {
                cmd.Connection  = conn;
                cmd.CommandText = getAllVehicleServiceDates;
                //conn.Open();
                SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                DataTable      ds    = new DataTable();
                adapt.Fill(ds);
                dgvServiceTrucks.DataSource = ds;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }

            //Vehicle Booked
            try
            {
                cmd.Connection  = conn;
                cmd.CommandText = getAllBookedVehicles;
                //conn.Open();
                SqlDataAdapter adapt = new SqlDataAdapter(cmd);
                DataTable      ds    = new DataTable();
                adapt.Fill(ds);
                dgvBookedTrucks.DataSource = ds;
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }

            //Initialize Chat
            InitializeConnection();
        }
コード例 #3
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            Bookings book = new Bookings();

            book.ShowDialog();
        }