コード例 #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            MaHS  = txtMaHS.Text;
            TenHS = txtTenHS.Text;
            MaBH  = cbBacHoc.SelectedValue.ToString();
            clsFunction f1 = new clsFunction();

            if (hanhdong == "them")
            {
                if (rbNam.Checked)
                {
                    Gioitinh = "Nam";
                }
                else
                {
                    Gioitinh = "Nu";
                }

                sql = "INSERT INTO HOC_SINH (MaHS,TenHS,Gioitinh,Ngaysinh,MaBH) VALUES ('" + MaHS + "','" + TenHS + "','" + Gioitinh + "','" + dtpNgaySinh.Value + "','" + MaBH + "')";
                f1.Them_Sua_Xoa(sql);
            }
            if (hanhdong == "sua")
            {
                if (rbNam.Checked)
                {
                    Gioitinh = "Nam";
                }
                else
                {
                    Gioitinh = "Nu";
                }

                sql = "UPDATE HOC_SINH SET TenHS = '" + TenHS + "',Gioitinh ='" + Gioitinh + "',Ngaysinh = '" + dtpNgaySinh.Value + "',MaBH = '" + MaBH + "' WHERE MaHS = '" + MaHS + "'";
                f1.Them_Sua_Xoa(sql);
            }
            if (hanhdong == "xoa")
            {
                sql = "DELETE FROM HOC_SINH WHERE MaHS = '" + MaHS + "'";
                f1.Them_Sua_Xoa(sql);
            }
            TaiDuLieu();
        }