Ejemplo n.º 1
0
 public Trip_Started(string from_par, string to_par, DriverData Cfm, int Trip_id, int Code_id)//***********
 {
     InitializeComponent();
     code_id   = Code_id;
     trip_id   = Trip_id;
     from.Text = from2 = from_par;
     to.Text   = to2 = to_par;
     CFM       = Cfm;
 }
Ejemplo n.º 2
0
        private void Accept_Request_Click_1(object sender, EventArgs e)
        {
            SqlCommand cmd;

            con.Open();
            cmd = new SqlCommand("select weight from location where loc_name like '" + from1 + "'", con);
            int from_weight = (int)cmd.ExecuteScalar();

            con.Close();

            con.Open();
            cmd = new SqlCommand("select weight from location where loc_name like '" + to1 + "'", con);
            int to_weight = (int)cmd.ExecuteScalar();

            con.Close();

            int fee = 0;

            if (from_weight > to_weight)
            {
                fee = ((from_weight - to_weight) * 5);
            }
            else
            {
                fee = ((from_weight - to_weight) * -5);
            }



            con.Open();
            cmd = new SqlCommand("insert into Trip (Pickup_Location , Destination , Distance, Passenger_ID_FK , Driver_ID_FK, Fee)values (@Pickup_Location , @Destination , @Distance, @Passenger_ID_FK , @Driver_ID_FK,@Fee);", con);
            SqlParameter par;

            par = new SqlParameter("@Pickup_Location", from1);
            cmd.Parameters.Add(par);
            par = new SqlParameter("@Destination", to1);
            cmd.Parameters.Add(par);

            SqlCommand cmd2  = new SqlCommand("select ID from Passenger where Email like '" + pp_email + "'", con);
            int        pp_id = (int)cmd2.ExecuteScalar();

            cmd2 = new SqlCommand("select ID from Driver where Email like '" + dd_mail + "'", con);
            int dd_id = (int)cmd2.ExecuteScalar();

            par = new SqlParameter("@Passenger_ID_FK", pp_id);//
            cmd.Parameters.Add(par);
            par = new SqlParameter("@Driver_ID_FK", dd_id);
            cmd.Parameters.Add(par);

            par = new SqlParameter("@Distance", (int)(fee / 5));
            cmd.Parameters.Add(par);

            par = new SqlParameter("@Fee", fee);
            cmd.Parameters.Add(par);

            cmd.ExecuteNonQuery();
            con.Close();

            con.Open();

            cmd = new SqlCommand("select max(ID)from Trip", con);
            int trip_id = (int)cmd.ExecuteScalar();

            con.Close();


            DriverData fm2 = new DriverData(dd_mail, trip_id);

            fm2.Show();

            Trip_Started fm = new Trip_Started(from1, to1, fm2, trip_id, code_id);//

            fm.Show();



            this.Close();
        }