예제 #1
0
 private void tabControl1_Click(object sender, EventArgs e)
 {
     cmboCategory.Items.AddRange(DBConnection.getCategorie().ToArray());
     cmboCategory.SelectedIndex = 0;
 }
예제 #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            // Add Order to OrderDetails
            if (DateTime.Compare(dateTimePicker2.Value, dateTimePicker3.Value) == 0)
            {
                MessageBox.Show("Please enter valid Pickup Time.");
            }

            //Constants.returnClientID();
            conn = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                string passengerName     = comboBox1.Text;
                string transportProvider = comboBox2.Text;
                string orderFor          = dateTimePicker1.Value.ToString();
                string pickupAddress     = textBox2.Text;
                string dropoffAddress    = textBox3.Text;


                if (string.IsNullOrEmpty(passengerName))
                {
                    MessageBox.Show("ERROR! Please select valid Passenger Name.");
                    isReadyToAdd = false;
                }
                else
                {
                    isReadyToAdd = true;
                }

                if (string.IsNullOrEmpty(transportProvider))
                {
                    MessageBox.Show("ERROR! Please select valid Transport Provider.");
                    isReadyToAdd = false;
                }
                else
                {
                    isReadyToAdd = true;
                }

                if (string.IsNullOrEmpty(orderFor))
                {
                    MessageBox.Show("ERROR! Please select valid Date.");
                    isReadyToAdd = false;
                }
                else
                {
                    isReadyToAdd = true;
                }

                if (string.IsNullOrEmpty(pickupAddress))
                {
                    MessageBox.Show("ERROR! Please select valid Pickup Address.");
                    isReadyToAdd = false;
                }
                else
                {
                    isReadyToAdd = true;
                }

                {
                    if (string.IsNullOrEmpty(isOneWay))
                    {
                        MessageBox.Show("Error! Please select valid Trip Type.");
                        isReadyToAdd = false;
                    }
                    else if (isOneWay == "Round Trip")
                    {
                        if (string.IsNullOrEmpty(dropoffAddress))
                        {
                            MessageBox.Show("ERROR! Please select valid Dropoff Address.");
                            isReadyToAdd = false;
                        }
                        else
                        {
                            isReadyToAdd = true;
                        }
                        if (string.IsNullOrEmpty(returnTime))
                        {
                            MessageBox.Show("Error! Please select valid Return Time.");
                            isReadyToAdd = false;
                        }
                        else
                        {
                            isReadyToAdd = true;
                        }
                    }
                    else
                    {
                        isReadyToAdd = true;
                    }
                }

                if (string.IsNullOrEmpty(type))
                {
                    MessageBox.Show("Error! Please select valid Vehicle Type.");
                    isReadyToAdd = false;
                }
                else
                {
                    isReadyToAdd = true;
                }

                if (string.IsNullOrEmpty(textBox8.Text.ToString()))
                {
                    MessageBox.Show("Please CALCULATE total payment amount.");
                    isReadyToAdd = false;
                }
                else
                {
                    isReadyToAdd = true;
                }


                if (isReadyToAdd && isOneWay == "Round Trip")
                {
                    string     query = "INSERT INTO OrderDetails(Transport_Provider_idTransport_Provider, Passenger_idPassenger, WC_Ambulatory, OrderDate, TotalPayment, isOne_Way, Date_for_Order, Pickup_Time, Pickup_Address, Drop_off_Address, ReturnTime) VALUES ((SELECT distinct idTransport_Provider from Transport_Provider WHERE Name = '" + transportProvider + "'), (SELECT idPassenger from Passenger WHERE Name = '" + passengerName + "'),'" + type + "', (SELECT GETDATE()), '" + totalAmount + "','" + isOneWay + "','" + orderFor + "','" + pickUpTime + "','" + pickupAddress + "','" + dropoffAddress + "','" + returnTime + "' )";
                    SqlCommand cm    = new SqlCommand(query, conn);
                    cm.ExecuteNonQuery();
                    MessageBox.Show("Order successfully added!");
                    cm.Dispose();
                    conn.Close();
                }
                else if (isReadyToAdd && isOneWay == "One Way")
                {
                    string     query = "INSERT INTO OrderDetails(Transport_Provider_idTransport_Provider, Passenger_idPassenger, WC_Ambulatory, OrderDate, TotalPayment, isOne_Way, Date_for_Order, Pickup_Time, Pickup_Address) VALUES ((SELECT idTransport_Provider from Transport_Provider WHERE Name = '" + transportProvider + "'), (SELECT idPassenger from Passenger WHERE Name = '" + passengerName + "'),'" + type + "', (SELECT GETDATE()), '" + totalAmount + "','" + isOneWay + "','" + orderFor + "','" + pickUpTime + "','" + pickupAddress + "' )";
                    SqlCommand cm    = new SqlCommand(query, conn);
                    cm.ExecuteNonQuery();
                    MessageBox.Show("Order successfully added!");
                    cm.Dispose();
                    conn.Close();
                }
            }
        }
예제 #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Book book = new Book(txtTitle.Text, cmboCategory.Text, txtDescription.Text, txtBookID.Text, Convert.ToInt32(numQty.Value), txtName.Text);

            DBConnection.updateBook(book);
        }