예제 #1
0
        private void roadSarchButton_Click(object sender, EventArgs e)
        {
            string lisenceNumber;

            lisenceNumber = searchLisenceTextBox.Text;
            roadPermitClass roadObj          = null;
            string          connectionString = @"server=DUET-559FE4FA51\SQLEXPRESS;integrated security = SSPI; database = VehicleInformationDB;";
            SqlConnection   connection       = new SqlConnection(connectionString);

            connection.Open();


            string        queryString = "SELECT * FROM roadInformationTable WHERE CarlisenceNumber='" + lisenceNumber + "'";
            SqlCommand    command     = new SqlCommand(queryString, connection);
            SqlDataReader reader      = command.ExecuteReader();

            while (reader.Read())
            {
                roadObj                      = new roadPermitClass();
                roadObj.TypeOfCar            = (reader["typeOfCar"]).ToString();
                typeOfCarComboBox.Text       = (reader["typeOfCar"]).ToString();
                roadObj.CarId                = (reader["carId"]).ToString();
                carIdTextBox.Text            = (reader["carId"]).ToString();
                roadObj.CarLisenceNumber     = (reader["carLisenceNumber"]).ToString();
                carLisenceNumbertextBox.Text = (reader["carLisenceNumber"]).ToString();
                roadObj.RoadPermit           = (reader["roadPermit"]).ToString();
                carRoadPermitTextBox.Text    = (reader["roadPermit"]).ToString();
            }
            MessageBox.Show("typeOfCar=" + roadObj.TypeOfCar + "\n carId=" + roadObj.CarId + "\n carLisenceNumber=" + roadObj.CarLisenceNumber + "\n \n roadPermit:" + roadObj.RoadPermit);

            connection.Close();
        }
예제 #2
0
        public void saveRoadInformation(roadPermitClass roadPermitObj)
        {
            string        connectionString = @"server=DUET-559FE4FA51\SQLEXPRESS;integrated security = SSPI; database = VehicleInformationDB;";
            SqlConnection connection       = new SqlConnection(connectionString);

            connection.Open();
            string     insertString = "INSERT INTO roadInformationTable VALUES('" + roadPermitObj.TypeOfCar + "','" + roadPermitObj.CarId + "','" + roadPermitObj.CarLisenceNumber + "','" + roadPermitObj.RoadPermit + "')";
            SqlCommand command      = new SqlCommand(insertString, connection);

            command.ExecuteNonQuery();
            connection.Close();
        }
예제 #3
0
        private void roadSaveButton_Click(object sender, EventArgs e)
        {
            roadPermitClass roadPermitObj = new roadPermitClass();

            roadPermitObj.TypeOfCar        = typeOfCarComboBox.Text;
            roadPermitObj.CarId            = carIdTextBox.Text;
            roadPermitObj.CarLisenceNumber = carLisenceNumbertextBox.Text;
            roadPermitObj.RoadPermit       = carRoadPermitTextBox.Text;
            roadInformationGetway getway = new roadInformationGetway();

            getway.saveRoadInformation(roadPermitObj);

            MessageBox.Show("inforMation Save");
        }
예제 #4
0
        public List <roadPermitClass> GetRoadInformation()
        {
            roadPermitClass        roadObj = null;
            List <roadPermitClass> roadPer = new List <roadPermitClass>();
            string        connectionString = @"server=DUET-559FE4FA51\SQLEXPRESS;integrated security = SSPI; database = VehicleInformationDB;";
            SqlConnection connection       = new SqlConnection(connectionString);

            connection.Open();
            string        queryString = "SELECT *FROM roadInformationTable";
            SqlCommand    command     = new SqlCommand(queryString, connection);
            SqlDataReader reader      = command.ExecuteReader();

            while (reader.Read())
            {
                roadObj                  = new roadPermitClass();
                roadObj.TypeOfCar        = (reader["typeOfCar"]).ToString();
                roadObj.CarId            = (reader["carId"]).ToString();
                roadObj.CarLisenceNumber = (reader["carLisenceNumber"]).ToString();
                roadObj.RoadPermit       = (reader["roadPermit"]).ToString();
                roadPer.Add(roadObj);
            }
            connection.Close();
            return(roadPer);
        }