//mot ham add du lieu public void addSV(object[] SV) { DataRow dr = DTSV.NewRow(); dr.ItemArray = SV; DTSV.Rows.Add(dr); }
public void setDataTable(object[] SV) { DataRow dr = DTSV.NewRow(); dr.ItemArray = SV; DTSV.Rows.Add(dr); }
public void AddDataRowSV(SV s) { DataRow dr1 = DTSV.NewRow(); dr1["MSSV"] = s.MSSV; dr1["Name"] = s.Name; dr1["Gender"] = s.Gender; dr1["NS"] = s.NS; dr1["ID_Lop"] = s.ID_Lop; DTSV.Rows.Add(dr1); }
/* * // Trả về DataTable có SV trùng với ID_Lop * public DataTable GetSVByIDLop(int id) * { * DataTable dt = new DataTable(); * dt.Columns.AddRange(new DataColumn[] * { * new DataColumn("MSSV", typeof(string)), * new DataColumn("NameSV", typeof(string)), * new DataColumn("Gender", typeof(bool)), * new DataColumn("NgaySinh", typeof(DateTime)), * new DataColumn("ID_Lop", typeof(string)), * }); * if (id != 0) * { * foreach (DataRow i in DTSV.Rows) * { * DataRow dr = dt.NewRow(); * if (Convert.ToInt32(i["ID_Lop"]) == id) * { * dr["MSSV"] = i["MSSV"]; dr["NameSV"] = i["NameSV"]; * dr["Gender"] = i["Gender"]; dr["ID_Lop"] = id; * dr["NgaySinh"] = i["NgaySinh"]; * dt.Rows.Add(dr); * } * } * } else * { * dt = DTSV; * } * return dt; * } * // Trả về DataTable có SV trùng với ms * public DataTable GetDTSVByMSSV(int ms) * { * DataTable dt = new DataTable(); * dt.Columns.AddRange(new DataColumn[] * { * new DataColumn("MSSV", typeof(string)), * new DataColumn("NameSV", typeof(string)), * new DataColumn("Gender", typeof(bool)), * new DataColumn("NgaySinh", typeof(DateTime)), * new DataColumn("ID_Lop", typeof(string)), * }); * if (ms != 0) * { * foreach (DataRow i in DTSV.Rows) * { * DataRow dr = dt.NewRow(); * if (Convert.ToInt32(i["MSSV"]) == ms) * { * dr["MSSV"] = i["MSSV"]; dr["NameSV"] = i["NameSV"]; * dr["Gender"] = i["Gender"]; dr["ID_Lop"] = i["ID_Lop"] ; * dr["NgaySinh"] = i["NgaySinh"]; * dt.Rows.Add(dr); * } * } * } * else * { * dt = DTSV; * } * return dt; * } * // Trả về DataTable có SV trùng với name * public DataTable GetDTSVByNameSV(string name) * { * DataTable dt = new DataTable(); * dt.Columns.AddRange(new DataColumn[] * { * new DataColumn("MSSV", typeof(string)), * new DataColumn("NameSV", typeof(string)), * new DataColumn("Gender", typeof(bool)), * new DataColumn("NgaySinh", typeof(DateTime)), * new DataColumn("ID_Lop", typeof(string)), * }); * if (name != "") * { * foreach (DataRow i in DTSV.Rows) * { * DataRow dr = dt.NewRow(); * if (i["NameSV"].ToString() == name) * { * dr["MSSV"] = i["MSSV"]; dr["NameSV"] = i["NameSV"]; * dr["Gender"] = i["Gender"]; dr["ID_Lop"] = i["ID_Lop"]; * dr["NgaySinh"] = i["NgaySinh"]; * dt.Rows.Add(dr); * } * } * } * else * { * dt = DTSV; * } * return dt; * } * // Trả về hàng có SV trùng với MSSV * public DataRow GetSVByMSSV(string ms) * { * DataRow dr = DTSV.NewRow(); * try * { * foreach (DataRow i in DTSV.Rows) * { * if (i["MSSV"].ToString() == ms) * { * dr = i; * } * } * return dr; * } * catch (Exception) * { * return null; * } * } * private bool CheckMSSV(string ms) * { * foreach(DataRow i in DTSV.Rows) * { * if (i["MSSV"].ToString() == ms) * { * return true; * } * } * return false; * } * public bool Add(params object[] data) * { * try * { * if (CheckMSSV(data[0].ToString())) * { * return false; * } else * { * DTSV.Rows.Add(new object[] * { * data[0], data[1], data[2], data[3], data[4] * }); * return true; * } * } * catch (Exception) * { * return false; * } * } * public bool Edit(params object[] data) * { * bool check = false; * try * { * foreach (DataRow i in DTSV.Rows) * { * if (i["MSSV"].ToString() == data[0].ToString()) * { * i["NameSV"] = data[1].ToString(); * i["Gender"] = Convert.ToBoolean(data[2].ToString()); * i["NgaySinh"] = Convert.ToDateTime(data[3].ToString()); * i["ID_Lop"] = data[4].ToString(); * check = true; * } * } * return check; * } * catch (Exception) * { * return false; * } * } * public bool Del(List<string> data) * { * try * { * foreach (string j in data) * { * foreach (DataRow i in DTSV.Select()) * { * if (i["MSSV"].ToString() == j) * { * DTSV.Rows.Remove(i); * } * } * DTSV.AcceptChanges(); * } * return true; * } * catch (Exception) * { * return false; * } * } */ /// KIEU MOI public void AddDataRow(SV s) { DataRow dr = DTSV.NewRow(); dr["MSSV"] = s.MSSV; dr["NameSV"] = s.NameSV; dr["Gender"] = s.Gender; dr["ID_Lop"] = s.ID_Lop; dr["NgaySinh"] = s.NgaySinh; DTSV.Rows.Add(dr); }
public void AddDr(SV s) { DataRow dr = DTSV.NewRow(); dr["MSSV"] = s.MSSV; dr["Name"] = s.Name; dr["NS"] = s.NS; dr["Gender"] = s.Gender; dr["ID_Lop"] = s.ID_Lop; }
public void AddNewRow(SV a) { DataRow b = DTSV.NewRow(); b["MSSV"] = a.MSSV; b["NameSV"] = a.NameSV; b["Gender"] = a.Gender; b["ID_Lop"] = a.ID_Lop; b["NS"] = a.NS.ToString().Split(' ')[0]; DTSV.Rows.Add(b); }
public void AddDataRow(SV s) { DataRow row8 = DTSV.NewRow(); row8["MSSV"] = s.MSSV; row8["NameSV"] = s.NameSV; row8["Gender"] = s.Gender; row8["Birthday"] = s.NS; row8["ClassID"] = s.ID_Lop; DTSV.Rows.Add(row8); }
public void DeleteDataRow(string MSSV) { foreach (DataRow i in DTSV.Select()) { if (i["MSSV"].ToString() == MSSV) { DTSV.Rows.Remove(i); } } DTSV.AcceptChanges(); }
public void CapNhatDSSV(List <SV> sv) { DTSV.Rows.Clear(); foreach (SV i in sv) { DataRow dataRow = DTSV.NewRow(); dataRow["MSSV"] = i.MSSV; dataRow["Name"] = i.Name; dataRow["Gender"] = i.Gender; dataRow["NS"] = i.NS; dataRow["ID_Lop"] = i.ID_Lop; DTSV.Rows.Add(dataRow); } }
/*public void addSV(List<SV> listsv) * { * DTSV.Rows.Clear(); * foreach (var s in listsv) * { * DataRow dr = DTSV.NewRow(); * dr["NameSV"] = s.NameSV; * dr["MSSV"] = s.MSSV; * dr["Gender"] = s.Gender; * dr["LopSH"] = s.ID_Lop; * dr["ns"] = s.NS; * DTSV.Rows.Add(dr); * } * * }*/ /*public void addSV(SV s) * { * * DataRow dr = DTSV.NewRow(); * dr["NameSV"] = s.NameSV; * dr["MSSV"] = s.MSSV; * dr["Gender"] = s.Gender; * dr["LopSH"] = s.ID_Lop; * dr["ns"] = s.NS; * DTSV.Rows.Add(dr); * * }*/ public void setSV(List <SV> listsv) // tao 1 csdl moi sau khi thao tac { DTSV.Rows.Clear(); foreach (var s in listsv) { DataRow sv = DTSV.NewRow(); sv["MSSV"] = s.MSSV; sv["NameSV"] = s.NameSV; sv["Gender"] = s.Gender; sv["NS"] = s.NS; sv["LopSH"] = s.ID_Lop; DTSV.Rows.Add(sv); } }
public void setDTSV(List <SV> s) { DTSV.Rows.Clear(); foreach (SV i in s) { DataRow dr = DTSV.NewRow(); dr["MSSV"] = i.MSSV; dr["HoTen"] = i.HoTen; dr["GioiTinh"] = i.GioiTinh; dr["ID_Lop"] = i.ID_Lop; dr["NgaySinh"] = i.NgaySinh; DTSV.Rows.Add(dr); } }
public void DeleteDataRow(SV s) { try { foreach (DataRow i in DTSV.Rows) { if (i["MSSV"].ToString() == s.MSSV) { DTSV.Rows.Remove(i); } } DTSV.AcceptChanges(); } catch (Exception) { } }
public void EditDataSV(SV s) { for (int i = 0; i < DTSV.Rows.Count; ++i) { if (DTSV.Rows[i]["MSSV"].ToString() == s.MSSV) { DTSV.Rows.RemoveAt(i); DataRow d = DTSV.NewRow(); d["MSSV"] = s.MSSV; d["NameSV"] = s.NameSV; d["NS"] = s.NS.ToString(); d["Gender"] = s.Gender.ToString(); d["ID_Lop"] = s.ID_Lop.ToString(); DTSV.Rows.InsertAt(d, i); return; } } }
public void sortForDemand(string demand) { DataRow temp = DTSV.NewRow(); for (int i = 0; i < DTSV.Rows.Count - 1; i++) { for (int j = i; j < DTSV.Rows.Count; j++) { if (String.Compare(DTSV.Rows[i][demand].ToString(), DTSV.Rows[j][demand].ToString()) > 0) { temp.ItemArray = DTSV.Rows[i].ItemArray; DTSV.Rows[i].ItemArray = DTSV.Rows[j].ItemArray; DTSV.Rows[j].ItemArray = temp.ItemArray; } } } }
public void sortForDemand(string demand) { DataRow dr = DTSV.NewRow(); string a = ""; string b = ""; for (int i = 0; i < DTSV.Rows.Count - 1; i++) { for (int j = i + 1; j < DTSV.Rows.Count; j++) { if (String.Compare(DTSV.Rows[i][demand].ToString(), DTSV.Rows[j][demand].ToString()) > 0) { dr.ItemArray = DTSV.Rows[i].ItemArray; DTSV.Rows[i].ItemArray = DTSV.Rows[j].ItemArray; DTSV.Rows[j].ItemArray = dr.ItemArray; } } } }