예제 #1
0
        private void btnsrchUp_Click(object sender, EventArgs e)
        {
            //string connString = @"Server=LAPTOP-D3473TU4;Database=Project;Integrated Security=true;";
            string connString = @"Server=DESKTOP-L6S3T5O\SQLEXPRESS; Database=Project ;Integrated Security=true;";
            //string connString = @"Server=NEEHAL\SQLEXPRESS;Database=Project;Integrated Security=true;";
            //string connString = @"Server=DESKTOP-VCKBA6J\SQLEXPRESS; Database=Project ;Integrated Security=true;";

            SqlConnection conn = new SqlConnection(connString);

            //List<PackShow> Package = new List<PackShow>();
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            int    Pack_id = Int32.Parse(tbTpIdUp.Text);
            string query   = string.Format("select * from Package where Pack_id= " + Pack_id);

            SqlCommand    cmd    = new SqlCommand(query, conn);
            SqlDataReader reader = cmd.ExecuteReader();

            PackShow p = new PackShow();

            while (reader.Read())
            {
                //PackShow p = new PackShow();
                p.Pack_id       = reader.GetInt32(reader.GetOrdinal("Pack_id"));
                p.Pack_name     = reader.GetString(reader.GetOrdinal("Pack_name"));
                p.Tour_duration = reader.GetString(reader.GetOrdinal("Tour_duration"));
                p.Pack_price    = reader.GetString(reader.GetOrdinal("Pack_price"));
                p.pack_feature  = reader.GetString(reader.GetOrdinal("pack_feature"));
                //Package.Add(p);
            }
            conn.Close();
            tbTpNameUp.Text = p.Pack_name;
            tbTDuUp.Text    = p.Tour_duration;
            tbTpPrUp.Text   = p.Pack_price;
            tbTpFUp.Text    = p.pack_feature;
        }
예제 #2
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            //string connString = @"Server=LAPTOP-D3473TU4;Database=Project;Integrated Security=true;";
            string connString = @"Server=DESKTOP-L6S3T5O\SQLEXPRESS; Database=Project ;Integrated Security=true;";
            //string connString = @"Server=NEEHAL\SQLEXPRESS;Database=Project;Integrated Security=true;";
            //string connString = @"Server=DESKTOP-VCKBA6J\SQLEXPRESS; Database=Project ;Integrated Security=true;";
            SqlConnection   conn    = new SqlConnection(connString);
            List <PackShow> Package = new List <PackShow>();

            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            string query = "select * from Package";

            try
            {
                SqlCommand    cmd    = new SqlCommand(query, conn);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    PackShow p = new PackShow();
                    p.Pack_id       = reader.GetInt32(reader.GetOrdinal("Pack_id"));
                    p.Pack_name     = reader.GetString(reader.GetOrdinal("Pack_name"));
                    p.Tour_duration = reader.GetString(reader.GetOrdinal("Tour_duration"));
                    p.Pack_price    = reader.GetString(reader.GetOrdinal("Pack_price"));
                    p.pack_feature  = reader.GetString(reader.GetOrdinal("pack_feature"));
                    Package.Add(p);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
            dtPackage.DataSource = Package;
        }