Esempio n. 1
0
 private void buttonKullaniciSil_Click(object sender, EventArgs e)
 {
     if (dataGridView2.SelectedRows[0].Cells[0].Value != null)
     {
         string       seciliogrencino = dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
         DialogResult res             = MessageBox.Show(seciliogrencino + " numaralı öğrenci bilgileri silinecektir.Onaylıyor musunuz?", "Kullanıcı Silme", MessageBoxButtons.YesNo);
         if (res == DialogResult.Yes)
         {
             using (var bdb = new BrowserContext(baglanti))
             {
                 var user = bdb.UserSet.FirstOrDefault(u => u.OgrenciNo == seciliogrencino);
                 if (user != null)
                 {
                     bdb.UserSet.Remove(user); bdb.SaveChanges();
                 }
             }
         }
         else
         {
             MessageBox.Show("İşlem İptal Edildi.", "İşlem İptal");
         }
         kullaniciGetir();
     }
     else
     {
         string       seciliusername = dataGridView2.SelectedRows[0].Cells[1].Value.ToString();
         DialogResult res            = MessageBox.Show(seciliusername + " kullanıcı adına sahip öğrenci bilgileri silinecektir.Onaylıyor musunuz?", "Kullanıcı Silme", MessageBoxButtons.YesNo);
         if (res == DialogResult.Yes)
         {
             using (var bdb = new BrowserContext(baglanti))
             {
                 var user = bdb.UserSet.FirstOrDefault(u => u.username == seciliusername);
                 if (user != null)
                 {
                     bdb.UserSet.Remove(user); bdb.SaveChanges();
                 }
             }
         }
         else
         {
             MessageBox.Show("İşlem İptal Edildi.", "İşlem İptal");
         }
         kullaniciGetir();
     }
 }
Esempio n. 2
0
        public void detaygoster(object sender, EventArgs e)
        {
            int userid = Convert.ToInt32(((PictureBox)sender).Tag.ToString());

            using (var bdb = new BrowserContext(baglanti))
            {
                var user = bdb.UserSet.FirstOrDefault(u => u.UserId == userid);
                if (user == null)
                {
                    return;
                }
                textBoxadsoyad.Text      = user.AdSoyad;
                textBoxkullaniciadi.Text = user.username;
                textBoxogrencino.Text    = user.OgrenciNo;
                textBoxsinifi.Text       = user.Sinif;
                var list = bdb.BrowserLogSet.Where(b => b.UserId == user.UserId).OrderByDescending(o => o.Tarih).Select(s => new { s.Adres, s.Tarih }).ToList();
                dataGridView1.DataSource = list;
            }
        }
Esempio n. 3
0
 private void button8_Click(object sender, EventArgs e) //KULLANICI GÜNCELLE
 {
     using (var bdb = new BrowserContext(baglanti))
     {
         int id      = Convert.ToInt32(labelid.Text);
         var ogrenci = bdb.UserSet.FirstOrDefault(u => u.UserId == id);
         if (ogrenci == null)
         {
             return;
         }
         ogrenci.username  = textBox4.Text;
         ogrenci.pass      = textBox5.Text;
         ogrenci.AdSoyad   = textBox3.Text;
         ogrenci.Sinif     = textBox1.Text;
         ogrenci.OgrenciNo = textBox2.Text;
         ogrenci.Izin      = Convert.ToInt32(radioButton1.Checked);
         bdb.SaveChanges();
         var list = bdb.UserSet.Select(s => new { s.OgrenciNo, s.username, s.AdSoyad, s.Sinif, s.Izin }).ToList();
         dataGridView2.DataSource = list;
     }
 }
Esempio n. 4
0
        public void AnasayfaOlustur()
        {
            timer1.Stop();
            while (flowLayoutPanel1.Controls.Count > 0)
            {
                foreach (Control control in flowLayoutPanel1.Controls)
                {
                    flowLayoutPanel1.Controls.Remove(control);
                    control.Dispose();
                }
            }

            using (var bdb = new BrowserContext(baglanti))
            {
                if (textBox10.Text == "")
                {
                    var users = bdb.UserSet.Where(u => u.Sinif.Contains(textBox9.Text)).ToList();
                    UserPanels = new List <Panel>();
                    foreach (var user in users)
                    {
                        if (user.Durum == 1 || textBox9.Text != "" || textBox10.Text != "")
                        {
                            Panel puser = new Panel();
                            puser.Size      = new Size(flowLayoutPanel1.Size.Width, 100);
                            puser.BackColor = Color.Transparent;
                            puser.Name      = user.username;

                            PictureBox pc = new PictureBox();
                            pc.Size       = new Size(120, 100);
                            pc.Location   = new Point(0, 0);
                            pc.Tag        = user.username;
                            pc.MouseDown += detaygoster;
                            pc.Tag        = user.UserId;
                            pc.SizeMode   = PictureBoxSizeMode.StretchImage;

                            Image image1 = null;
                            using (FileStream stream = new FileStream(user.Durum + ".jpg", FileMode.Open))
                            { image1 = Image.FromStream(stream); }
                            pc.Image = image1;

                            if (user.Izin == 0)
                            {
                                using (FileStream stream = new FileStream("kirmizi.jpg", FileMode.Open))
                                { image1 = Image.FromStream(stream); }
                                pc.Image = image1;
                            }

                            TextBox adtxt = new TextBox();
                            adtxt.ReadOnly = true;
                            adtxt.Location = new Point(130, 0);
                            try { adtxt.Text = user.AdSoyad; } catch (Exception) { }
                            adtxt.Tag  = user.username;
                            adtxt.Font = new Font("Arial", 8.0f);
                            adtxt.Size = new Size(puser.Size.Width - 180, 20);

                            RichTextBox urltxt = new RichTextBox();
                            urltxt.ReadOnly = true;
                            urltxt.Location = new Point(130, 22);
                            try { urltxt.Text = bdb.BrowserLogSet.OrderByDescending(o => o.Tarih).FirstOrDefault(l => l.UserId == user.UserId).Adres; } catch (Exception) { }
                            urltxt.Tag  = user.username;
                            urltxt.Font = new Font("Arial", 8.0f);
                            urltxt.Size = new Size(puser.Size.Width - 180, 78);
                            UserPanels.Add(puser);

                            puser.Controls.Add(pc);
                            puser.Controls.Add(adtxt);
                            puser.Controls.Add(urltxt);
                            flowLayoutPanel1.Controls.Add(puser);
                        }
                    }
                }
                else
                {
                    var users = bdb.UserSet.Where(u => u.OgrenciNo == textBox10.Text).ToList();
                    UserPanels = new List <Panel>();
                    foreach (var user in users)
                    {
                        if (user.Durum == 1 || textBox9.Text != "" || textBox10.Text != "")
                        {
                            Panel puser = new Panel();
                            puser.Size      = new Size(flowLayoutPanel1.Size.Width, 100);
                            puser.BackColor = Color.Transparent;
                            puser.Name      = user.username;

                            PictureBox pc = new PictureBox();
                            pc.Size       = new Size(120, 100);
                            pc.Location   = new Point(0, 0);
                            pc.Tag        = user.username;
                            pc.MouseDown += detaygoster;
                            pc.Tag        = user.UserId;
                            pc.SizeMode   = PictureBoxSizeMode.StretchImage;

                            Image image1 = null;
                            using (FileStream stream = new FileStream(user.Durum + ".jpg", FileMode.Open))
                            { image1 = Image.FromStream(stream); }
                            pc.Image = image1;

                            if (user.Izin == 0)
                            {
                                using (FileStream stream = new FileStream("kirmizi.jpg", FileMode.Open))
                                { image1 = Image.FromStream(stream); }
                                pc.Image = image1;
                            }

                            TextBox adtxt = new TextBox();
                            adtxt.ReadOnly = true;
                            adtxt.Location = new Point(130, 0);
                            try { adtxt.Text = user.AdSoyad; } catch (Exception) { }
                            adtxt.Tag  = user.username;
                            adtxt.Font = new Font("Arial", 8.0f);
                            adtxt.Size = new Size(puser.Size.Width - 180, 20);

                            RichTextBox urltxt = new RichTextBox();
                            urltxt.ReadOnly = true;
                            urltxt.Location = new Point(130, 22);
                            try { urltxt.Text = bdb.BrowserLogSet.OrderByDescending(o => o.Tarih).FirstOrDefault(l => l.UserId == user.UserId).Adres; } catch (Exception) { }
                            urltxt.Tag  = user.username;
                            urltxt.Font = new Font("Arial", 8.0f);
                            urltxt.Size = new Size(puser.Size.Width - 180, 78);
                            UserPanels.Add(puser);

                            puser.Controls.Add(pc);
                            puser.Controls.Add(adtxt);
                            puser.Controls.Add(urltxt);
                            flowLayoutPanel1.Controls.Add(puser);
                        }
                    }
                }
            }
            timer1.Start();
        }