private void btnThem_Click(object sender, EventArgs e) { try { HOCSINH hs = new HOCSINHF().FindEntity(int.Parse(lueHS.EditValue.ToString())); if(hs!=null) { hs.malop = int.Parse(lueLop.EditValue.ToString()); new HOCSINHF().Update(hs); Init_Grid(); } } catch { } }
private void btnLuu_Click(object sender, EventArgs e) { try { HOCSINH model = new HOCSINH() { hoten = txtHoTen.Text, ngaysinh = Convert.ToDateTime(dateNS.Text), diachi = txtDiaChi.Text, sdt = txtDienThoai.Text, }; int ID_ = -1; if (txtMaHS.Text != "") { ID_ = int.Parse(txtMaHS.Text.ToString()); } model.mahs = ID_; if (txtMaHS.Text == "") { var result = new HOCSINHF().Insert(model); if (result) { MessageBox.Show("Done"); } else { MessageBox.Show("Lỗi"); } } else { var result = new HOCSINHF().Update(model); if (result) { MessageBox.Show("Done"); } else { MessageBox.Show("Lỗi"); } } Init_(); ClearBinding(); Bindingtxt(); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
private void btnXoa_Click(object sender, EventArgs e) { try { DialogResult result = MessageBox.Show("Bạn có muốn xóa nhà cung cấp " + txtHoTen.Text + " không?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { var ans = new HOCSINHF().Delete(new HOCSINH { mahs = int.Parse(txtMaHS.Text) }); Init_(); ClearBinding(); Bindingtxt(); } } catch { } }
private void btnXoa_Click(object sender, EventArgs e) { try { int[] selRows = ((GridView)GridHS.MainView).GetSelectedRows(); HOCSINH hs = (HOCSINH)(((GridView)GridHS.MainView).GetRow(selRows[0])); DialogResult result = MessageBox.Show("Bạn có muốn xóa học sinh " +hs.hoten + " khỏi lớp " +lueLop.Text+" không?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (hs != null) { hs.malop = null; bool ans = new HOCSINHF().Update(hs); Init_Grid(); } } } catch { } }