//ham phuc vu ham add public void addGV(GV g) { List <GV> list = CSDL_OOP.Instance.getDataGV(); list.Add(g); CSDL.Instance.setDataGV(list); }
//Lam ham edit //1. //mot ham bat du lieu day du cua Sv tu CSDL_OOP sau do show len public void showInforGV() { GV g = CSDL_OOP.Instance.getInforGV(msgv); txtMSGV.Text = g.ID_GV.ToString(); txtNameGV.Text = g.NameGV; txtNumber.Text = g.SDT; dateTimePicker1.Value = g.NS; cbbMaCS.Text = CSDL_OOP.Instance.getNameCSByIDCS(idcs); }
//ham add mot sv bang mot datarow public GV getSV(DataRow dr) { GV g = new GV(); g.ID_GV = Convert.ToInt32(dr["ID_GV"]); g.NameGV = dr["Name"].ToString(); g.SDT = dr["SDT"].ToString(); g.NS = Convert.ToDateTime(dr["NS"]); g.ID_CS = dr["ID_CS"].ToString(); return(g); }
//mot ham lay info giao vien tu view tra ve giao vien private GV getInforGV() { GV g = new GV(); g.ID_GV = Convert.ToInt32(txtMSGV.Text); g.NameGV = txtNameGV.Text; g.SDT = txtNumber.Text; g.NS = dateTimePicker1.Value; g.ID_CS = CSDL_OOP.Instance.getIDCSByCSName(cbbMaCS.Text); return(g); }
//ham updateSV public void updateDTSV(int mssv, GV g) { List <GV> list = getDataGV(); int index = 0; foreach (GV temp in list) { if (list[index].ID_GV == mssv) { list[index] = g; break; } } CSDL.Instance.setDataGV(list); }
//Làm một list SV đổ dữ liệu từ bên CSDL.DTGV qua bên List GV và trả về list GV public List <GV> getDataGV() { List <GV> dataGV = new List <GV>(); foreach (DataRow dr in CSDL.Instance.DTGV.Rows) { GV g = new GV(); g.ID_GV = Convert.ToInt32(dr["ID_GV"].ToString()); g.NameGV = dr["Name"].ToString(); g.SDT = dr["SDT"].ToString(); g.NS = Convert.ToDateTime(dr["NS"].ToString()); g.ID_CS = dr["ID_CS"].ToString(); dataGV.Add(g); } return(dataGV); }
//lay du lieu cua thang GV tu msgv minh da chon public GV getInforGV(int msgv) { GV g = new GV(); foreach (DataRow dr in CSDL.Instance.DTGV.Rows) { if (Convert.ToInt32(dr["ID_GV"].ToString()) == msgv) { g.ID_GV = Convert.ToInt32(dr["ID_GV"].ToString()); g.NameGV = dr["Name"].ToString(); g.SDT = dr["SDT"].ToString(); g.NS = Convert.ToDateTime(dr["NS"].ToString()); g.ID_CS = dr["ID_CS"].ToString(); return(g); } } return(g); }