예제 #1
0
        private void tim_Click(object sender, EventArgs e)
        {
            if (kq.kiemtraquyenuser(FormDangnhap.loginUsename, "sinhvien", "view") == true)
            {
                SinhVienRepositories sv = new SinhVienRepositories();
                string makhoa           = "";
                string malop            = "";
                if (khoa.SelectedItem == null)
                {
                    makhoa = "";
                }
                else
                {
                    makhoa = ((KeyValuePair <string, string>)khoa.SelectedItem).Value;
                }
                if (lophoc.SelectedItem == null)
                {
                    malop = "";
                }
                else
                {
                    malop = ((KeyValuePair <string, string>)lophoc.SelectedItem).Value;
                }
                dataGridView1.DataSource = sv.findsv(masvt.Text.Trim(), makhoa, malop);

                /*  if (dataGridView1.RowCount > 0)
                 *    for (int i = 0; i < dataGridView1.RowCount; i++)
                 *        dataGridView1.Rows[i].Cells["Ma"].Value = "Bạn ko có quyền xem";*/
                dataGridView1.Refresh();
            }
            else
            {
                MessageBox.Show("Bạn không có quyền thực hiện lệnh này");
            }
        }
예제 #2
0
        private void nhapsvexcel_Click(object sender, EventArgs e)
        {
            if (kq.kiemtraquyenuser(FormDangnhap.loginUsename, "sinhvien", "add") == true)
            {
                openFileDialog1.ShowDialog();

                string pathToExcelFile  = "" + @openFileDialog1.FileName;
                string loi              = "";
                SinhVienRepositories sv = new SinhVienRepositories();
                // try
                // {
                sv.nhapsv_excel(ref loi, pathToExcelFile);
                if (loi == "")
                {
                    MessageBox.Show("Đã đọc file Excel thành công");
                }
                else
                {
                    MessageBox.Show("Các dòng bị lỗi trong file Excel bạn muốn import vào " + loi);
                }
                // }
                // catch { MessageBox.Show("Đã có lỗi trong quá trình đọc file Excel"); }
            }
            else
            {
                MessageBox.Show("Bạn không có quyền thực hiện lệnh này");
            }
        }
예제 #3
0
        private void them_Click(object sender, EventArgs e)
        {
            string ma = ketnoicsdl.taomatudong("sinhvien");

            if (kq.kiemtraquyenuser(FormDangnhap.loginUsename, "sinhvien", "add") == true)
            {
                if (masv.Text.Trim() != "")
                {
                    masv.Text = "";
                }
                else
                {
                    string loi = "";

                    if (ck.kiemtragiatrirong(Tensv.Text) + ck.kiemtragiatrirong(ngaysinh.Text) +
                        ck.kiemtragiatrirong(gioitinh.Text) + ck.kiemtragiatrirong(cmbLop.Text) + ck.kiemtragiatrirong(bacdaotao.Text)
                        + ck.kiemtragiatrirong(khoahoc.Text) + ck.kiemtragiatrirong(cmnd.Text) >= 1)
                    {
                        MessageBox.Show("Bạn phải nhập cái phần bắt buộc có dấu chấm than ");
                        hien();
                    }
                    else
                    {
                        SinhVienRepositories sv = new SinhVienRepositories();
                        try
                        {
                            sv.addsv_Luu(ref loi, ma, Tensv.Text, ngaysinh.Text, gioitinh.Text, diachi.Text, dienthoai.Text,
                                         cmbLop.Text, bacdaotao.Text, Convert.ToInt32(khoahoc.Text), ((KeyValuePair <string, string>)khoasv.SelectedItem).Value.ToString(), Convert.ToInt32(cmnd.Text));
                        }
                        catch { MessageBox.Show("Đã có thuộc tính null trong thông tin sinh viên"); }
                        if (loi == "")
                        {
                            MessageBox.Show("Đã nhập thông tin thành công");
                        }
                        else
                        {
                            MessageBox.Show("Các thông tin bị lỗi" + loi);
                        }
                    }
                    //   MessageBox.Show(ketnoicsdl.taomatudong("sinhvien"));
                }

                /*  else {
                 *    masv.Text = ketnoicsdl.taomatudong("sinhvien");
                 *    Tensv.Text = "";
                 *    diachi.Text = "";
                 *    dienthoai.Text = "";
                 *    cmnd.Text = "";
                 *
                 * }*/
            }
            else
            {
                MessageBox.Show("Bạn không có quyền thực hiện lệnh này");
            }
        }
예제 #4
0
        private void luu_Click(object sender, EventArgs e)
        {
            if (kq.kiemtraquyenuser(FormDangnhap.loginUsename, "sinhvien", "up") == true)
            {
                Khoa k = kh.getByName(khoasv.Text);
                SinhVienRepositories sv = new SinhVienRepositories();
                if (sv.updatesv(masv.Text, Tensv.Text, ngaysinh.Text, diachi.Text, gioitinh.Text, dienthoai.Text,
                                cmbLop.Text, khoahoc.Text, k.Makhoa, bacdaotao.Text, cmnd.Text) == 1)
                {
                    MessageBox.Show("Bạn đã cập nhật thành công");
                }
            }

            else
            {
                MessageBox.Show("Bạn không có quyền thực hiện lệnh này");
            }
        }
예제 #5
0
 private void xoasv_Click(object sender, EventArgs e)
 {
     if (kq.kiemtraquyenuser(FormDangnhap.loginUsename, "sinhvien", "del") == true)
     {
         if (System.Windows.Forms.MessageBox.Show("bạn có chắc chắn muốn xóa không?.", "Overwrite", System.Windows.Forms.MessageBoxButtons.OKCancel,
                                                  System.Windows.Forms.MessageBoxIcon.Asterisk, System.Windows.Forms.MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.OK)
         {
             SinhVienRepositories sv = new SinhVienRepositories();
             if (sv.xoasv(masv.Text) == 1)
             {
                 MessageBox.Show("Bạn đã xóa thành công");
             }
             dataGridView1.Refresh();
         }
     }
     else
     {
         MessageBox.Show("Bạn không có quyền thực hiện lệnh này");
     }
 }