Example #1
0
 private void btLuu_Click(object sender, EventArgs e)
 {
     if (XacNhan == false)
     {
         lbThongBao.Visible = true;
         pnXacNhan.Visible  = true;
         return;
     }
     if (btLuu.Text == "Thêm")
     {
         txbMatKhau.Enabled = true;
         btLuu.Text         = "Lưu";
     }
     else if (btLuu.Text == "Lưu")
     {
         string ID      = TaoID();
         string MatKhau = txbMatKhau.Text;
         if (MatKhau == "")
         {
             return;
         }
         EC_TaiKhoan ecTK = new EC_TaiKhoan(ID, txbTenDN.Text, Hash.getHashString(MatKhau));
         new BUS_TaiKhoan().ThemDuLieu(ecTK);
         if (cbLoai.SelectedIndex == 0)
         {
             EC_QuanLyTrungTam ecQl = new EC_QuanLyTrungTam();
             ecQl.ID = ID;
             new BUS_QuanLyTrungTam().ThemDuLieu(ecQl);
         }
         else if (cbLoai.SelectedIndex == 1)
         {
             BUS_GiaoVien busGv = new BUS_GiaoVien();
             if (busGv.Select_ByPrimaryKey(txbMa.Text) == null)
             {
                 MessageBox.Show("Không tồn tại giáo viên");
                 return;
             }
             busGv.ThemID(txbMa.Text, ID);
         }
         else if (cbLoai.SelectedIndex == 2)
         {
             BUS_HocSinh busHS = new BUS_HocSinh();
             if (busHS.Select_ByPrimaryKey(txbMa.Text) == null)
             {
                 MessageBox.Show("Không tồn tại học sinh");
                 return;
             }
             busHS.ThemID(txbMa.Text, ID);
         }
         btLuu.Text = "Thêm";
     }
     else
     {
     }
     LoadForm();
 }
Example #2
0
 private void btLuu_Click(object sender, EventArgs e)
 {
     if (btLuu.Text == "Lưu")
     {
         EC_TaiKhoan ecTK = new EC_TaiKhoan(txbID.Text, txbTenDN.Text, txbMatKhau.Text);
         busTK.SuaDuLieu(ecTK);
         btLuu.Text    = "Thêm";
         txbID.Enabled = txbMa.Enabled = txbTenDN.Enabled = cbLoai.Enabled = true;
     }
     else if (btLuu.Text == "Thêm")
     {
         string      ID   = TaoID();
         EC_TaiKhoan ecTK = new EC_TaiKhoan(ID, txbTenDN.Text, txbMatKhau.Text);
         if (cbLoai.SelectedIndex == 0)
         {
             EC_QuanLyTrungTam ecQl = new EC_QuanLyTrungTam();
             ecQl.ID = ID;
         }
         else if (cbLoai.SelectedIndex == 1)
         {
             BUS_GiaoVien busGv = new BUS_GiaoVien();
             if (busGv.Select_ByPrimaryKey(txbMa.Text) == null)
             {
                 MessageBox.Show("Không tồn tại giáo viên");
                 return;
             }
             busGv.ThemID(txbMa.Text, ID);
         }
         else if (cbLoai.SelectedIndex == 2)
         {
             BUS_HocSinh busHS = new BUS_HocSinh();
             if (busHS.Select_ByPrimaryKey(txbMa.Text) == null)
             {
                 MessageBox.Show("Không tồn tại học sinh");
                 return;
             }
             busHS.ThemID(txbMa.Text, ID);
         }
     }
     else
     {
     }
     LoadForm();
 }