public void AddNewRow(GV a) { DataRow b = DTGV.NewRow(); b["MaGV"] = a.MaGV; b["TenGV"] = a.TenGV; b["SDT"] = a.SDT; b["MaCS"] = a.MaCS; b["NS"] = a.NS.ToString().Split(' ')[0]; DTGV.Rows.Add(b); }
public void DeleteRow(GV a) { foreach (DataRow item in Instance.DTGV.Rows) { if ((int)item["MaGV"] == a.MaGV) { Instance.DTGV.Rows.Remove(item); break; } } }
GV CellClick(DataGridViewRow row) { GV s = new GV(); s.MaGV = (int)row.Cells["MaGV"].Value; s.TenGV = row.Cells["TenGV"].Value.ToString(); s.MaCS = row.Cells["MaCS"].Value.ToString(); s.NS = Convert.ToDateTime(row.Cells["NS"].Value); s.SDT = row.Cells["SDT"].Value.ToString(); return(s); }
public void EditRow(GV a) { foreach (DataRow item in Instance.DTGV.Rows) { if ((int)item["MaGV"] == a.MaGV) { item["TenGV"] = a.TenGV; item["NS"] = a.NS.ToString().Split(' ')[0]; item["SDT"] = a.SDT; item["MaCS"] = a.MaCS; } } }
void Add(GV a) { if (CSDL_OOP.Instance.AddNewGV(a, true)) { dtgvGV.DataSource = null; dtgvGV.DataSource = ListGV; MessageBox.Show("Added Successfully"); } else { MessageBox.Show("error"); } }
private void btnOK_Click(object sender, EventArgs e) { if (Validate()) { GV gv = new GV(); gv.MaGV = Convert.ToInt32(txtMaGV.Text); gv.TenGV = txtTenGV.Text; gv.SDT = txtSDT.Text; gv.MaCS = GetID(); gv.NS = Convert.ToDateTime(datepicker.Value); profile(gv); } ; this.Close(); }
void Edit(GV a) { DataGridViewRow row = dtgvGV.CurrentRow; GV i = new GV(); i = CellClick(row); if (a.MaGV == i.MaGV && CSDL_OOP.Instance.AddNewGV(a, false)) { dtgvGV.DataSource = null; dtgvGV.DataSource = ListGV; MessageBox.Show("Edit Successfully"); } else { MessageBox.Show("Error Edit"); } }
public GV GetGV(DataRow row) { GV a = new GV(); DataTable dt = CSDL.Instance.DTGV; foreach (DataRow item in dt.Rows) { if (row == item) { a.MaGV = (int)item["MaGV"]; a.TenGV = item["TenGV"].ToString(); a.SDT = item["SDT"].ToString(); a.NS = Convert.ToDateTime(item["NS"]); a.MaCS = item["ID_Lop"].ToString(); } } return(a); }
private void btnDel_Click(object sender, EventArgs e) { DataGridViewRow row = dtgvGV.CurrentRow; if (row != null) { GV a = new GV(); a = CellClick(row); DialogResult result = MessageBox.Show("Bạn có muốn xóa SV này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { dtgvGV.DataSource = null; CSDL_OOP.Instance.DeleteSV(a); dtgvGV.DataSource = ListGV; MessageBox.Show("Delete Successfully"); } } }
public bool AddNewGV(GV gv, bool isAdd) { if (isAdd) { if (checkMaGV(gv.MaGV)) { CSDL.Instance.AddNewRow(gv); Instance.GetAllGV(); return(true); } return(false); } else { CSDL.Instance.EditRow(gv); Instance.GetAllGV(); return(true); } }
public List <GV> GetListGV(string MaCS) { List <GV> s = new List <GV>(); DataTable dt = CSDL.Instance.DTGV; foreach (DataRow item in dt.Rows) { if (item["MaCS"].ToString() == MaCS) { GV a = new GV(); a.MaGV = (int)item["MaGV"]; a.TenGV = item["TenGV"].ToString(); a.SDT = item["SDT"].ToString(); a.NS = Convert.ToDateTime(item["NS"]); a.MaCS = item["MaCS"].ToString(); s.Add(a); } } return(s); }
public List <GV> GetAllGV() { if (ListGV != null) { ListGV.Clear(); } else { ListGV = new List <GV>(); } foreach (DataRow item in CSDL.Instance.DTGV.Rows) { GV s = new GV(); s.MaGV = (int)(item["MaGV"]); s.TenGV = item["TenGV"].ToString(); s.SDT = item["SDT"].ToString(); s.MaCS = item["MaCS"].ToString(); s.NS = Convert.ToDateTime(item["NS"]); ListGV.Add(s); } return(ListGV); }
public void DeleteSV(GV gv) { CSDL.Instance.DeleteRow(gv); Instance.GetAllGV(); }