示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            QLDSK_MaKhoa = "Them";
            DCTTK edit = new DCTTK();

            edit.Show();
        }
示例#2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentCell.ColumnIndex == 2)
            {
                DCTTK edit = new DCTTK();
                QLDSK_MaKhoa = dataGridView1.Rows[e.RowIndex].Cells["MaKhoa"].Value.ToString();
                edit.Show();
            }
            else if (dataGridView1.CurrentCell.ColumnIndex == 3)
            {
                DialogResult confirm = MessageBox.Show("Are you f*****g sure - This will delete the corresponding Sinh Vien, Diem and Login!", "Warning", MessageBoxButtons.YesNo);
                if (confirm == DialogResult.Yes)
                {
                    string MaKhoa = dataGridView1.Rows[e.RowIndex].Cells["MaKhoa"].Value.ToString();

                    var o = (from s in SV.tbl_DangNhap
                             where s.MaKhoa == MaKhoa
                             select s).ToList();
                    for (int i = 0; i < o.Count; i++)
                    {
                        SV.tbl_DangNhap.Remove(o[i]);
                    }

                    var p = (from s in SV.tbl_SinhVien
                             where s.MaKhoa == MaKhoa
                             select s).ToList();
                    for (int i = 0; i < p.Count; i++)
                    {
                        string mssv = p[i].MSSV;
                        var    l    = (from s in SV.tbl_Diem
                                       where s.MSSV == mssv
                                       select s).ToList();
                        for (int g = 0; g < l.Count; g++)
                        {
                            SV.tbl_Diem.Remove(l[g]);
                        }
                        SV.tbl_SinhVien.Remove(p[i]);
                    }
                    SV.tbl_Khoa.Remove((from s in SV.tbl_Khoa
                                        where s.MaKhoa == MaKhoa
                                        select s).FirstOrDefault());
                    SV.SaveChanges();
                    MessageBox.Show("Deleted successfully!");
                    Main.ReloadKhoa();
                }
            }
        }