コード例 #1
0
        private void Back_Click(object sender, EventArgs e)
        {
            try
            {
                sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

                cmd = new SqlCommand(sql, con);

                DataReader = cmd.ExecuteReader();

                while (DataReader.Read())
                {
                    output  = "";
                    output += DataReader.GetValue(0);
                }

                Name = output;

                DataReader.Close();
                cmd.Dispose();
                con.Close();

                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
        }
コード例 #2
0
        private void Done_Click(object sender, EventArgs e)
        {
            try
            {
                string Name  = NameTxtBox.Text;
                string Email = IDTxtBox.Text;

                sql = "";

                /*
                 * UPDATE [dbo].[PASSENGER] SET [NAME] = 'Laila',  [EMAIL] = '*****@*****.**'
                 * WHERE [PASSENGER_ID] = 'AA111
                 */
                sql = "UPDATE [dbo].[PASSENGER] SET [NAME] = '" + Name + "',  [EMAIL] = '" + Email + "' WHERE [PASSENGER_ID] = '" + ID + "'";
                cmd = new SqlCommand(sql, con);

                DataAdapter = new SqlDataAdapter();
                DataAdapter.InsertCommand = new SqlCommand(sql, con);

                DataAdapter.InsertCommand.ExecuteNonQuery();

                MessageBox.Show("your data is updated");

                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();

                con.Close();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
            return;
        }
コード例 #3
0
        private void AddFlightBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string Date        = DateTimeTB.Text;
                string Destination = DestTB.Text;
                string PiltID      = PilotIDTB.Text;
                string nStops      = nStopsTB.Text;
                string Duration    = DurationTB.Text;
                string Source      = SourceTB.Text;
                string FlightID    = FlightIDTB.Text;
                string nSeats      = nSeatsTB.Text;

                DataAdapter = new SqlDataAdapter();
                sql         = "";

                sql = "INSERT INTO [dbo].[FLIGHT] VALUES( '" + Date + "' , '" + Destination + "' , '" + PiltID + "' , " + nStops + ", " + Duration + " , '" + Source + "' , '" + FlightID + "' , " + nSeats + ")";

                cmd = new SqlCommand(sql, con);

                DataAdapter.InsertCommand = new SqlCommand(sql, con);

                DataAdapter.InsertCommand.ExecuteNonQuery();

                DataAdapter.Dispose();
                cmd.Dispose();

                //***************************************

                sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

                cmd = new SqlCommand(sql, con);

                DataReader = cmd.ExecuteReader();

                while (DataReader.Read())
                {
                    output  = "";
                    output += DataReader.GetValue(0);
                }

                Name = output;

                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();

                DataReader.Close();
                cmd.Dispose();
                con.Close();

                return;
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
            MessageBox.Show("You wrote invalid data");
        }
コード例 #4
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string PID = PIDTB.Text;

                DataAdapter = new SqlDataAdapter();
                sql         = "";
                //DELETE FROM [dbo].[AIRCRAFT] WHERE [PLANE_ID] = '00'

                sql = "DELETE FROM [dbo].[AIRCRAFT] WHERE [PLANE_ID] = '" + PID + "'";

                cmd = new SqlCommand(sql, con);

                DataAdapter.InsertCommand = new SqlCommand(sql, con);

                DataAdapter.InsertCommand.ExecuteNonQuery();

                MessageBox.Show("one Craft is Deleted");

                DataAdapter.Dispose();
                cmd.Dispose();

                ///**************************************************************************
                sql = "";
                sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

                cmd = new SqlCommand(sql, con);

                DataReader = cmd.ExecuteReader();

                while (DataReader.Read())
                {
                    output  = "";
                    output += DataReader.GetValue(0);
                }

                Name = output;

                ///*******************************************************
                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();

                cmd.Dispose();
                con.Close();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
        }
コード例 #5
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string Name = NameTxtBox.Text;
                string ID   = IDTxtBox.Text;

                //SELECT [TYPE] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] = 'AA110' AND [NAME] like 'Aymen'


                sql = "SELECT [TYPE] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] = '" + ID + "' AND [NAME] like '" + Name + "'";

                cmd        = new SqlCommand(sql, con);
                DataReader = cmd.ExecuteReader();

                output = "";
                while (DataReader.Read())
                {
                    output += DataReader.GetValue(0);
                    if (output == "Admen")
                    {
                        // Here i should open a form that contain the operation that admin can perform.

                        AdmenForm form = new AdmenForm(Name, ID);
                        this.Hide();
                        form.Show();

                        DataReader.Close();
                        cmd.Dispose();

                        return;
                    }

                    output = "";
                }
                // Here i should open a form that contain the operation that USER can perform.

                /*
                 * UserForm form = new UserForm();
                 * this.Hide();
                 * form.Show();
                 */
                MessageBox.Show("USER FORM :D");
                DataReader.Close();
                cmd.Dispose();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string Model = ModelTxtBox.Text;
                string newID = IDTxtBox.Text;
                string Cname = CNameTxtBox.Text;
                string nPass = nPassTxtBox.Text;
                string Year  = MYearTxtBox.Text;

                DataAdapter = new SqlDataAdapter();
                sql         = "";
                //INSERT INTO [dbo].[AIRCRAFT] VALUES ( 'AC' , 'AC110' ,'The Boeing',450, 2015)
                sql = "INSERT INTO [dbo].[AIRCRAFT] VALUES ( '" + Model + "' , '" + newID + "' ,'" + Cname + "'," + nPass + " , " + Year + ")";

                cmd = new SqlCommand(sql, con);

                DataAdapter.InsertCommand = new SqlCommand(sql, con);

                DataAdapter.InsertCommand.ExecuteNonQuery();
                ///******************************************************
                sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

                cmd = new SqlCommand(sql, con);

                DataReader = cmd.ExecuteReader();

                while (DataReader.Read())
                {
                    output  = "";
                    output += DataReader.GetValue(0);
                }

                Name = output;

                ///*******************************************************
                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();

                cmd.Dispose();
                con.Close();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
        }
コード例 #7
0
        private void BackBtn_Click(object sender, EventArgs e)
        {
            this.tICKETTableAdapter.Update(this.flight_ReservationDataSet.TICKET);

            //***************************************
            sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

            cmd = new SqlCommand(sql, con);

            DataReader = cmd.ExecuteReader();

            while (DataReader.Read())
            {
                output  = "";
                output += DataReader.GetValue(0);
            }

            Name = output;

            AdmenForm form = new AdmenForm(Name, ID);

            this.Hide();
            form.Show();
        }
コード例 #8
0
        private void AddFlightBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isFound)
                {
                    MessageBox.Show("You didn't write a valid Flight number to update the Flight");
                    return;
                }
                ///Read new Fligth Data :
                string Date        = DateTimeTB.Text;
                string Destination = DestTB.Text;
                string PiltID      = PilotIDTB.Text;
                string nStops      = nStopsTB.Text;
                string Duration    = DurationTB.Text;
                string Source      = SourceTB.Text;
                string nSeats      = nSeatsTB.Text;

                /*
                 * 1- Search for the Flight using the ID
                 * 2- Update it using SQL query
                 * */
                ///*****************************************************
                ///Update the Flight data using Queries:-
                DataAdapter = new SqlDataAdapter();
                sql         = "";

                /*
                 * UPDATE [dbo].[FLIGHT]
                 *  SET [DATE_AND_TIME] = '' , [DESTINATION_CITY] = '', [N_STOPS] = 00
                 *  , [DURATION] = 00  , [DEPARTURE_CITY] = '' , [N_AVAILABLESEATS] = 00
                 *  WHERE [FLIGHT_NO] = ''
                 * */
                sql  = "UPDATE [dbo].[FLIGHT]";
                sql += " SET [DATE_AND_TIME] = '" + Date + "' ,[DESTINATION_CITY] = '" + Destination + "', [N_STOPS] = " + nStops;
                sql += " , [DURATION] =" + Duration + ", [DEPARTURE_CITY] = '" + Source + "' , [N_AVAILABLESEATS] = " + nSeats;
                sql += " WHERE [FLIGHT_NO] = '" + FlightID + "'";
                cmd  = new SqlCommand(sql, con);

                DataAdapter.InsertCommand = new SqlCommand(sql, con);

                DataAdapter.InsertCommand.ExecuteNonQuery();

                DataAdapter.Dispose();
                cmd.Dispose();

                //***************************************
                // just get the Admin name to get back to its home page
                sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

                cmd = new SqlCommand(sql, con);

                DataReader = cmd.ExecuteReader();

                while (DataReader.Read())
                {
                    output  = "";
                    output += DataReader.GetValue(0);
                }

                Name = output;

                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();

                DataReader.Close();
                cmd.Dispose();
                con.Close();
                return;
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
            MessageBox.Show("You wrote invalid data");
        }
コード例 #9
0
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isFound)
                {
                    MessageBox.Show("You didn't write a valid Flight number to update the Flight");
                    return;
                }
                ///Read new craft Data :
                string Model       = ModelTxtBox.Text;
                string companyName = CNameTxtBox.Text;
                string nPassengers = nPassTxtBox.Text;
                string ModelYear   = MYearTxtBox.Text;

                /*
                 * 1- Search for the craft using the ID
                 * 2- Update it using SQL query
                 * */
                ///*****************************************************
                ///Update the Flight data using Queries:-

                DataAdapter = new SqlDataAdapter();
                sql         = "";

                /*
                 * Update [dbo].[AIRCRAFT]
                 *  SET [MODEL] = '00' , [COMPANY_NAME] = 'Airbus SE' , [N_PASSENGERS] = 00 ,[MODEL_YEAR] = 00
                 *  WHERE [PLANE_ID] = '00'
                 * */
                sql  = "Update [dbo].[AIRCRAFT]";
                sql += "SET [MODEL] = '" + Model + "' , [COMPANY_NAME] = '" + companyName + "' , [N_PASSENGERS] = " + nPassengers
                       + " ,[MODEL_YEAR] = " + ModelYear;
                sql += " WHERE [PLANE_ID] = '" + planeID + "'";
                cmd  = new SqlCommand(sql, con);

                DataAdapter.InsertCommand = new SqlCommand(sql, con);

                DataAdapter.InsertCommand.ExecuteNonQuery();

                DataAdapter.Dispose();
                cmd.Dispose();

                //***************************************
                // just get the Admin name to get back to its home page
                sql = "SELECT [NAME] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] like '" + ID + "'";

                cmd = new SqlCommand(sql, con);

                DataReader = cmd.ExecuteReader();

                while (DataReader.Read())
                {
                    output  = "";
                    output += DataReader.GetValue(0);
                }

                Name = output;

                AdmenForm form = new AdmenForm(Name, ID);
                this.Hide();
                form.Show();

                DataReader.Close();
                cmd.Dispose();
                con.Close();
                return;
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
            MessageBox.Show("You wrote invalid data");
        }