public KhenThuongInfo ListViewItemToInfo(ListViewItem item) { KhenThuongInfo hd = new KhenThuongInfo(); hd.MaKhenThuong = Convert.ToInt32(item.Text); hd.TenKhenThuong = item.SubItems[1].Text; return(hd); }
public KhenThuongInfo ControlToInfo(TextBox txtMa, TextBox txtTen) { KhenThuongInfo hd = new KhenThuongInfo(); hd.MaKhenThuong = Convert.ToInt32(txtMa.Text); hd.TenKhenThuong = txtTen.Text; return(hd); }
private void btnKetThuc_Click(object sender, EventArgs e) { if (ctrl.KiemTra(txtMa, txtTen)) { KhenThuong = ctrl.ControlToInfo(txtMa, txtTen); this.DialogResult = DialogResult.OK; } }
public ListViewItem DataRowToListViewItem(DataRow row) { ListViewItem item = new ListViewItem(); item.Text = row["MAHOATDONG"].ToString(); item.SubItems.Add(row["TENHOATDONG"].ToString()); KhenThuongInfo info = ListViewItemToInfo(item); item.Tag = info; return(item); }
private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa không?", "Hoạt Động", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (ctrl.KiemTra(txtMa, txtTen)) { KhenThuongInfo hoatdong = ctrl.ControlToInfo(txtMa, txtTen); ctrl.Xoa(hoatdong); ctrl.LayLenListView(listKhenThuong); } } }
public bool Xoa(KhenThuongInfo hoatdong) { SqlCommand com = new SqlCommand("Delete HOATDONG where MAHOATDONG=@ma"); com.Parameters.Add("@ma", SqlDbType.Int).Value = hoatdong.MaKhenThuong; try { ser.Load(com); return(true); } catch (Exception e) { e.ToString(); return(false); } }
public bool Sua(KhenThuongInfo hoatdong) { SqlCommand com = new SqlCommand("Update HOATDONG set TENHOATDONG=@ten where MAHOATDONG=@ma"); com.Parameters.Add("@ma", SqlDbType.Int).Value = hoatdong.MaKhenThuong; com.Parameters.Add("@ten", SqlDbType.NVarChar, 30).Value = hoatdong.TenKhenThuong; try { ser.Load(com); return(true); } catch (Exception e) { e.ToString(); return(false); } }
public bool Them(KhenThuongInfo hoatdong) { SqlCommand com = new SqlCommand("Insert into HOATDONG(MAHOATDONG,TENHOATDONG) values(@ma,@ten)"); com.Parameters.Add("@ma", SqlDbType.Int).Value = hoatdong.MaKhenThuong; com.Parameters.Add("@ten", SqlDbType.NVarChar, 30).Value = hoatdong.TenKhenThuong; try { ser.Load(com); return(true); } catch (Exception e) { e.ToString(); return(false); } }
private void btnLuu_Sua_Click(object sender, EventArgs e) { if (ctrl.KiemTra(txtMa, txtTen)) { KhenThuongInfo phong = ctrl.ControlToInfo(txtMa, txtTen); ctrl.Sua(phong); ctrl.LayLenListView(listKhenThuong); Updating = false; btnSua.Text = "Sửa"; btnXoa.Enabled = true; btnThem.Enabled = true; btnKetThuc.Visible = true; btnLuu_Them.Visible = false; btnLuu_Sua.Visible = false; listKhenThuong.Enabled = true; txtMa.Enabled = false; txtTen.Enabled = false; } }
public bool Sua(KhenThuongInfo phong) { return(data.Sua(phong)); }
public bool Xoa(KhenThuongInfo phong) { return(data.Xoa(phong)); }
public bool Them(KhenThuongInfo phong) { return(data.Them(phong)); }