예제 #1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (Mypublic.TonTaiKhoaChinh(txtMSLop.Text, "MSLop", "SinhVien"))
     {
         MessageBox.Show("Phải xóa sinh viên thuộc lớp trước!");
     }
     else
     {
         DialogResult blnDongY;
         blnDongY = MessageBox.Show("Bạn thật sự muốn xóa?", "Xác nhận", MessageBoxButtons.YesNo);
         if (blnDongY == DialogResult.Yes)
         {
             string strDelete = "Delete Lop Where MSLop = @MSLop";
             if (Mypublic.conMyConnection.State == ConnectionState.Closed)
             {
                 Mypublic.conMyConnection.Open();
             }
             SqlCommand cmdConmand = new SqlCommand(strDelete, Mypublic.conMyConnection);
             cmdConmand.Parameters.AddWithValue("@MSLop", txtMSLop.Text);
             cmdConmand.ExecuteNonQuery();
             Mypublic.conMyConnection.Close();
             dgvLop.Rows.RemoveAt(dgvLop.CurrentRow.Index);
             GanDuLieu();
         }
     }
 }
예제 #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            int Khoa;

            if ((txtMSLop.Text == "") || (txtTenLop.Text == "") || (!int.TryParse(txtKhoaHoc.Text, out Khoa)) || (Khoa <= 0))
            {
                MessageBox.Show("Lỗi nhập dữ liệu !");
            }
            else
            {
                if ((blnThem) & (Mypublic.TonTaiKhoaChinh(txtMSLop.Text, "MSLop", "Lop")))
                {
                    MessageBox.Show("Mã số lớp này đã có rồi!");
                    txtMSLop.Focus();
                }
                else
                {
                    bsLop.EndEdit();
                    daLop.Update(dsLop, "Lop");
                    dsLop.AcceptChanges();
                    blnThem = false;
                    DieuKhienKhiBinhThuong();
                }
            }
        }
예제 #3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            int khoa;

            if ((txtMSLop.Text == "") || (txtTenLop.Text == "") || (txtKhoaHoc.Text == "") || (!int.TryParse(txtKhoaHoc.Text, out khoa)) || (khoa <= 0))
            {
                MessageBox.Show("Lỗi nhập dữ liệu!");
            }
            else
            {
                if (blnThem)
                {
                    if (Mypublic.TonTaiKhoaChinh(txtMSLop.Text, "MSLop", "Lop"))
                    {
                        MessageBox.Show("Mã số lớp này đã có rồi!");
                        txtMSLop.Focus();
                    }
                    else
                    {
                        LuuLopMoi();
                    }
                }
                else
                {
                    CapNhapLop();
                }
            }
        }
예제 #4
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (Mypublic.TonTaiKhoaChinh(txtMSLop.Text, "MSLop", "SinhVien"))
     {
         MessageBox.Show("Phải xóa sinh viên thuộc lớp trước!");
     }
     else
     {
         DialogResult blnDongY;
         blnDongY = MessageBox.Show("Bạn thật sự muốn xóa?", "Xác nhận", MessageBoxButtons.YesNo);
         if (blnDongY == DialogResult.Yes)
         {
             bsLop.RemoveCurrent();
             daLop.Update(dsLop, "Lop");
             dsLop.AcceptChanges();
         }
     }
     DieuKhienKhiBinhThuong();
 }