private void btnAraclariGoster_Click(object sender, EventArgs e)
        {
            Araclar      a               = new Araclar();
            YakitTuru    yt              = new YakitTuru();
            SanzimanTuru st              = new SanzimanTuru();
            int          secilenMarka    = a.MarkaNo;
            int          secilenYakit    = yt.YakitTuruId;
            int          secilenSanziman = st.SanzimanTuruId;

            try
            {
                var sonuc = db.Araclar.Select(x => new
                {
                    secilenMarka = x.Marka.MarkaNo,
                    x.Marka.AracMarka,
                    x.Model,
                    secilenYakit = x.YakitTuru.YakitTuruId,
                    x.YakitTuru.YakitAdi,
                    secilenSanziman = x.SanzimanTuru.SanzimanTuruId,
                    x.SanzimanTuru.SanzimanAdi,
                    x.GunlukFiyat,
                    x.KiradaMi
                }).Where(x => (int)cbMarkalar.SelectedValue == x.secilenMarka && (int)cbYakitTuru.SelectedValue == x.secilenYakit && (int)cbSanzimanTuru.SelectedValue == x.secilenSanziman && x.KiradaMi == false).ToList();
                dgvAraclar.DataSource         = sonuc;
                dgvAraclar.Columns[0].Visible = false;
                dgvAraclar.Columns[3].Visible = false;
                dgvAraclar.Columns[5].Visible = false;
                dgvAraclar.Columns[8].Visible = false;
            }
            catch (Exception ex)
            {
                string hata = ex.Message;
            }
        }
예제 #2
0
 private void dgvAraclar_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     aracid = (int)dgvAraclar.SelectedRows[0].Cells[0].Value;
     m      = db.Marka.Find(aracid);
     cbMarkalar.SelectedValue = m.MarkaNo;
     txtModelAdi.Text         = dgvAraclar.SelectedRows[0].Cells[2].Value.ToString();
     txtModelYili.Text        = dgvAraclar.SelectedRows[0].Cells[3].Value.ToString();
     yt = db.YakitTuru.Find(YakitTuruIdYakala());
     cbYakitTuru.SelectedValue = yt.YakitTuruId;
     st = db.SanzimanTuru.Find(SanzimanTuruIdYakala());
     cbSanzimanTuru.SelectedValue = st.SanzimanTuruId;
     txtGunlukFiyat.Text          = dgvAraclar.SelectedRows[0].Cells[6].Value.ToString();
     gunlukfiyat             = Convert.ToDecimal(dgvAraclar.SelectedRows[0].Cells[6].Value);
     btnEkle.Visible         = false;
     btnYeni.Visible         = false;
     btnSil.Visible          = true;
     btnDegistir.Visible     = true;
     txtGunlukFiyat.ReadOnly = false;
     txtModelAdi.Focus();
 }