private void btnChonBai_Click(object sender, EventArgs e) { frmBai f = new frmBai(); f.ShowDialog(); id_chon = f.id_chon; f.Dispose(); BaiHoc bh = MyFunction.ThongtinBaihoc(id_chon); if (bh == null) { return; } baihocTV = bh; HienThiBaiHoc(); }
private void lstBaihoc_SelectedIndexChanged(object sender, EventArgs e) { if (lstBaihoc.SelectedIndices.Count <= 0) { return; } int intselectedindex = lstBaihoc.SelectedIndices[0]; if (intselectedindex >= 0) { String id = lstBaihoc.Items[intselectedindex].SubItems[0].Text; txtID.Text = id; BaiHoc bh = MyFunction.ThongtinBaihoc(int.Parse(id)); txtTieude.Text = bh.tieude; txtNoidung.Text = MyFunction.NoidungToText(bh.baihoc); txtThutu.Text = bh.thutu.ToString(); } }
BaiHoc lay_baihoc() { if (bai_chon == -1) { MyFunction.FromXml_NoiCau(); danhsachNoiCau = MyFunction.danhsachBaihoc; } if (danhsachNoiCau.Count == 0) { return(null); } //Random randomBaihoc = new Random(); //int idx = randomBaihoc.Next(0, danhsachNoiCau.Count); BaiHoc bai = null; if (bai_chon == -1) { bai = danhsachNoiCau.OrderBy(x => x.thutu).ToList().FirstOrDefault(); } else { bai = MyFunction.danhsachBaihoc.OrderBy(x => x.thutu).ToList().FirstOrDefault(x => x.thutu > bai_chon); } if (bai == null) { bai_chon = -1; MessageBox.Show("Hết rồi !!!"); return(null); } baihocTV = bai; bai_chon = bai.thutu; return(bai); }
private void btnBaiKe_Click(object sender, EventArgs e) { BaiHoc baike = null; if (baihocTV == null) { baike = MyFunction.danhsachBaihoc.OrderBy(x => x.thutu).ToList().FirstOrDefault(); } else { baike = MyFunction.danhsachBaihoc.OrderBy(x => x.thutu).ToList().FirstOrDefault(x => x.thutu > baihocTV.thutu); } if (baike == null) { MessageBox.Show("Đây là bài cuối !!!"); return; } baihocTV = baike; HienThiBaiHoc(); }
private void btnBaiTruoc_Click(object sender, EventArgs e) { BaiHoc bai = null; if (baihocTV == null) { bai = MyFunction.danhsachBaihoc.OrderBy(x => x.thutu).ToList().LastOrDefault(); } else { bai = MyFunction.danhsachBaihoc.OrderBy(x => x.thutu).ToList().LastOrDefault(x => x.thutu < baihocTV.thutu); } if (bai == null) { MessageBox.Show("Đây là bài đầu tiên !!!"); return; } baihocTV = bai; HienThiBaiHoc(); }
private void btnXoa_Click(object sender, EventArgs e) { if (txtID.Text != "") { BaiHoc bh = MyFunction.danhsachBaihoc.FirstOrDefault(x => x.Id == int.Parse(txtID.Text)); if (bh != null) { try { MyFunction.danhsachBaihoc.Remove(bh); MyFunction.ToXml(); load_listBaihoc(); } catch (Exception ex) { MessageBox.Show("Khong Xoa Duoc"); return; } } } init_input(); }