Пример #1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            open_file_dialog.ShowDialog();
            textBox1.Text = open_file_dialog.FileName;
            string dosya_yolu = open_file_dialog.FileName;

            OleDbConnection deneme = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;  Data Source = " + dosya_yolu + "; Extended Properties = Excel 12.0");

            deneme.Open();
            string           sorgu        = "select * from [Arabalar$] ";
            OleDbDataAdapter data_adaptor = new OleDbDataAdapter(sorgu, deneme);

            deneme.Close();

            DataTable dt = new DataTable();

            data_adaptor.Fill(dt);
            dataGridView1.DataSource                  = dt;
            dataGridView1.Columns["sil"].Visible      = false;
            dataGridView1.Columns["guncelle"].Visible = false;
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                string     cumle = "insert into tblArac values('" + dataGridView1.Rows[i].Cells["marka"].Value + "','" + dataGridView1.Rows[i].Cells["model"].Value + "','" + dataGridView1.Rows[i].Cells["plaka"].Value + "','" + dataGridView1.Rows[i].Cells["yakit_turu"].Value + "'," + dataGridView1.Rows[i].Cells["motor_gucu"].Value + "," + dataGridView1.Rows[i].Cells["tork"].Value + "," + dataGridView1.Rows[i].Cells["motor_hacmi"].Value + ",'" + dataGridView1.Rows[i].Cells["renk"].Value + "','" + dataGridView1.Rows[i].Cells["vites"].Value + "'," + dataGridView1.Rows[i].Cells["klima"].Value + "," + dataGridView1.Rows[i].Cells["ruhsat_no"].Value + "," + dataGridView1.Rows[i].Cells["sigorta"].Value + ",'" + dataGridView1.Rows[i].Cells["muayne_bit_tar"].Value.ToString() + "'," + dataGridView1.Rows[i].Cells["ucret"].Value + "," + dataGridView1.Rows[i].Cells["kiraDurumu"].Value + ")";
                SqlCommand komut = new SqlCommand(cumle, baglanti);
                komut.ExecuteNonQuery();
            }
            MessageBox.Show("Yükleme İşlemi başarılı", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.Hide();
            baglanti.Close();
            araclar a = new araclar();

            a.Show();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)

        {
            araclar a = new araclar();

            if (ytk.yetkiAnahtar.ToString() == "OKUYUCU")
            {
                a.button1.Enabled = false;
                a.importY.Enabled = false;
            }
            a.Show();
        }
Пример #3
0
        private void AracEkle_FormClosed(object sender, FormClosedEventArgs e)
        {
            baglanti.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from tblArac", baglanti);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            araclar a = new araclar();

            a.dataGridView1.DataSource = dt;
            a.Show();
            baglanti.Close();
        }
Пример #4
0
        private void AracGuncelle_FormClosed(object sender, FormClosedEventArgs e)
        {
            string sql = "select * from tblArac";

            if (baglanti.State == ConnectionState.Closed)
            {
                baglanti.Open();
            }
            SqlDataAdapter da = new SqlDataAdapter(sql, baglanti);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            araclar a = new araclar();

            a.dataGridView1.DataSource = dt;
            a.Show();
            baglanti.Close();
        }