private void button2_Click(object sender, EventArgs e)
        {
            conn = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                string username = textBox1.Text;
                string password = textBox2.Text;

                string         LoginQuery = "SELECT count(1) FROM Client WHERE Username = '******' AND Password = HASHBYTES('SHA1', '" + password + "')";
                SqlDataAdapter sda        = new SqlDataAdapter(LoginQuery, conn);
                DataTable      dt         = new DataTable();
                sda.Fill(dt);

                if (dt.Rows[0][0].ToString() == "1")
                {
                    MessageBox.Show("Login successful!");
                    Constants.loginClientUser = username;
                    this.Hide();
                    new Form2().Show();
                }

                else
                {
                    MessageBox.Show("Login unsuccessful! Incorrect username and/or password.");
                }
            }
        }
Beispiel #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            // this will calculate the payment and display in the payment box
            //int oneWayFee;
            oneWayFee = 0;
            conn      = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                if (comboBox2.SelectedItem != null)
                {
                    transportProviderName = comboBox2.SelectedItem.ToString();
                    Console.WriteLine(transportProviderName);
                    string     getOneWayFee = "select top 1 One_Way_Payment from Transport_Provider where Name = '" + transportProviderName + "' order by One_Way_Payment desc ";
                    SqlCommand cm3          = new SqlCommand(getOneWayFee, conn);
                    cm3.CommandText = getOneWayFee;
                    SqlDataReader drd3 = cm3.ExecuteReader();

                    while (drd3.Read())
                    {
                        Console.WriteLine(drd3["One_Way_Payment"]);
                        oneWayFee = float.Parse(drd3["One_Way_Payment"].ToString());
                    }



                    if (radioButton1.Checked == true)     //oneway
                    {
                        if (radioButton4.Checked == true) //wheelchair
                        {
                            oneWayFee = oneWayFee + 4;
                        }
                        else if (radioButton3.Checked == true) //ambulatory
                        {
                            oneWayFee = oneWayFee + 8;
                        }
                    }

                    else if (radioButton2.Checked == true) //roundtrip
                    {
                        oneWayFee = oneWayFee * 2;
                        if (radioButton4.Checked == true) //wheelchair
                        {
                            oneWayFee = oneWayFee + 4;
                        }
                        else if (radioButton3.Checked == true) //ambulatory
                        {
                            oneWayFee = oneWayFee + 8;
                        }
                    }
                }

                conn.Close();
            }
            textBox8.Text = oneWayFee.ToString();
            oneWayFee     = 0;
        }
        public static string returnClientID()
        {
            conn = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                string     findClientID = "SELECT idClient FROM Client WHERE Username = '******'";
                SqlCommand searchcmd    = new SqlCommand(findClientID, conn);
                searchcmd.CommandText = findClientID;
                SqlDataReader data_set = searchcmd.ExecuteReader();

                while (data_set.Read())
                {
                    clientID = data_set["idClient"].ToString();
                }
                conn.Close();
            }
            return(clientID);
        }
Beispiel #4
0
        public Form4()
        {
            InitializeComponent();
            dateTimePicker2.CustomFormat = "  HH' : 'mm ";
            dateTimePicker2.Format       = DateTimePickerFormat.Custom;

            dateTimePicker1.CustomFormat = "MM/dd/yyyy";

            dateTimePicker3.CustomFormat = "  HH' : 'mm ";
            dateTimePicker3.Format       = DateTimePickerFormat.Custom;

            conn = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                string     SelectAll = "SELECT distinct Name FROM Passenger";
                SqlCommand cm        = new SqlCommand(SelectAll, conn);
                cm.CommandText = SelectAll;
                SqlDataReader drd = cm.ExecuteReader();

                while (drd.Read())
                {
                    comboBox1.Items.Add(drd["Name"].ToString());
                }
                conn.Close();

                conn = DBConnection.OpenConnection();
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    string     SelectTransport = "SELECT distinct Name FROM Transport_Provider";
                    SqlCommand cm2             = new SqlCommand(SelectTransport, conn);
                    cm2.CommandText = SelectTransport;
                    SqlDataReader drd2 = cm2.ExecuteReader();

                    while (drd2.Read())
                    {
                        comboBox2.Items.Add(drd2["Name"].ToString());
                    }
                }
            }
            conn.Close();
        }
Beispiel #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     Constants.returnClientID();
     conn = DBConnection.OpenConnection();
     if (conn.State == System.Data.ConnectionState.Open)
     {
         string name     = textBox2.Text;
         string phoneNum = textBox4.Text;
         if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(phoneNum))
         {
             MessageBox.Show("ERROR! Please enter valid Name and Phone Number.");
         }
         else
         {
             string     query = "INSERT INTO Passenger VALUES (" + Constants.clientID + ", '" + name + "', '" + phoneNum + "')";
             SqlCommand cm    = new SqlCommand(query, conn);
             cm.ExecuteNonQuery();
             MessageBox.Show("Passenger added!");
             cm.Dispose();
             conn.Close();
         }
     }
 }
        public Form6()
        {
            InitializeComponent();

            conn = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                string SelectAll = "SELECT * FROM Transport_Provider";

                SqlCommand cm = new SqlCommand(SelectAll, conn);

                cm.CommandText = SelectAll;

                SqlDataReader drd = cm.ExecuteReader();
                while (drd.Read())
                {
                    comboBox1.Items.Add(drd["Name"].ToString());
                    comboBox3.Items.Add(drd["One_Way_Payment"].ToString());
                    comboBox4.Items.Add(drd["Return_Payment"].ToString());
                }
                drd.Close();
            }
        }
        public Form5()
        {
            InitializeComponent();
            conn = DBConnection.OpenConnection();
            if (conn.State == System.Data.ConnectionState.Open)
            {
                string SelectAll = "SELECT * FROM Passenger";

                SqlCommand cm = new SqlCommand(SelectAll, conn);

                cm.CommandText = SelectAll;

                SqlDataReader drd = cm.ExecuteReader();
                while (drd.Read())
                {
                    comboBox1.Items.Add(drd["Name"].ToString());
                    comboBox3.Items.Add(drd["Phone_Number"].ToString());
                }
                drd.Close();
            }


            //con.Close();
        }
Beispiel #8
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();
                }
            }
        }