/// <summary> /// lấy sinh viên theo mã sinh viên /// </summary> /// <param name="idStudent"></param> /// <returns> Sinh viên có mã tương ứng hoặc null </returns> public static Student GetStudent(string idStudent) // khởi tạo dữ liệu mẫu Mock Data { Student student = new Student { IDStudent = idStudent, FirstName = "Minh", LastName = "Võ", DOB = new DateTime(1998, 2, 5), Gender = GENDER.Male }; //student.ListHistoryLearning student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 0; i < 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "THCS...", IDStudent = idStudent, }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
/// <summary> /// Lấy sinh viên theo mã sinh viên từ MockData /// </summary> /// lấy sv từ file /// <param name="pathDataFile">đường dẫn tới file chứa dư xlieeuj</param> /// <param name="idStudent">Ma sv</param> /// <returns>Sinh viên có mã tương ứng hoặc null</returns> public static Student GetStudent(string idStudent) { Student student = new Student { IDStudent = idStudent, FirstName = "Linh", LastName = "Nguyễn", DOB = new DateTime(1997, 12, 01), POB = "Quang Binh", Gender = GENDER.Female }; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 1; i <= 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "THCS Phan Bội Châu", IDStudent = idStudent, }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
public static List <HistoryLearning> GetAllHistoryLearning(string pathDataFile) { if (File.Exists(pathDataFile)) { List <HistoryLearning> hl = new List <HistoryLearning>(); //Mở file đọc hết toàn bộ các dòng tỏng file xong đóng file lại var listLines = File.ReadAllLines(pathDataFile); foreach (var lines in listLines) { var rs = lines.Split(new char[] { '#' }); HistoryLearning history = new HistoryLearning { IDHistoryLearning = rs[0], YearFrom = int.Parse(rs[1]), YearEnd = int.Parse(rs[2]), Address = rs[3], IDStudent = null }; } return(hl); } else { return(null); } }
/// <summary> Lấy sinh viên theo mã sinh viên từ MockData /// </summary> /// <param name="idStudent">Mã sinh viên</param> /// <returns>Sinh viên có mã tương ứng hoặc null</returns> public static student GetStudent(string idStudent) { student student = new student { IDStudent = idStudent, FirstName = "Giang", LastName = "Nguyễn", DOB = new DateTime(1998, 1, 26), POB = "Quảng Trị", Gender = GENDER.Female }; //student.ListHistoryLearning = null; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 0; i < 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2004 + i, YearEnd = 2005 + i, Address = "TH Gio Mai", IDStudent = idStudent, }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
/// <summary> /// Lấy sinh viên theo mã sinh viên /// </summary> /// <param name="" /// <param name="idStudent">Mã sinh viên</param> /// <returns>Sinh viên có mã tương ứng hoặc null</returns> public static Student GetStudent(string idStudent, string maSinhVien) { Student student = new Student { IDStudent = idStudent, FirstName = "Loi", LastName = "Duong", DOB = new DateTime(2000, 01, 01), POB = "Thừa Thiên Huế", Gender = GENDER.Male }; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 1; i <= 5; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "THCS Phu Xuan", IDStudent = idStudent, }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
/// <summary> /// Lay sinh vien theo ma sinh vien /// </summary> /// <param name="idStudent">Ma sinh vien</param> /// <returns>Sinh vien co ma tuong ung hoac null</returns> public static Student GetStudent(string idStudent) { Student student = new Student { IDStudent = idStudent, FirstName = "Phuc", LastName = "Ngo Hoang Duc", DOB = new DateTime(1997, 10, 3), POB = "Thua Thien Hue", Gender = GENDER.Male }; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 0; i < 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "Thua Thien Hue", IDStudent = idStudent }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
public static List <HistoryLearning> GetHistoryLearnings(string pathDataFile, string idStudent) { if (File.Exists(pathDataFile)) { var ListLines = File.ReadAllLines(pathDataFile); List <HistoryLearning> listHistory = new List <HistoryLearning>(); foreach (var line in ListLines) { var rs = line.Split(new char[] { '#' }); HistoryLearning history = new HistoryLearning { IDHistoryLearning = rs[0], YearFrom = int.Parse(rs[1]), YearTo = int.Parse(rs[2]), Address = rs[3], IDStudent = rs[4] }; if (history.IDStudent == idStudent) { listHistory.Add(history); } } return(listHistory); } else { return(null); } }
/// <summary> /// ba xoẹt : lấy sinh viên theo mã sinh viên từ mockdata /// </summary> /// <param name="idStudent"> Mã Sinh Viên</param> /// <returns>Sinh viên có max tương ứng hoặc null</returns> public static Student GetStudent(string idStudent) { Student student = new Student { IDStudent = idStudent, FirstName = "Ánh", LastName = "Trần Ngọc", DOB = new DateTime(1997, 1, 25), POB = "Thừa Thiên Huế", Gender = GENDER.Male }; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 1; i <= 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearTo = 2007 + i, Address = "THPT An Lương Đông", IDStudent = idStudent, }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
public static void EditHistoryLearning(HistoryLearning history, string pathHistoryLearningDataFile) { if (File.Exists(pathHistoryLearningDataFile)) { string[] listLinesHistoryLearning = File.ReadAllLines(pathHistoryLearningDataFile); //Lấy file ra , nên dùng var cho an toàn File.WriteAllText(pathHistoryLearningDataFile, ""); // Làm cho file đó trống foreach (var lineHistory in listLinesHistoryLearning) { var ls = lineHistory.Split(new char[] { '#' }); var line = "\n"; if (lineHistory == listLinesHistoryLearning[listLinesHistoryLearning.Length - 1]) { line = ""; } if (ls[0] != history.IDHistoryLearning) { File.AppendAllText(pathHistoryLearningDataFile, lineHistory + line); //Append là thêm vào, chèn vào sau chuỗi có trước, thêm vào ở File nào, nội dung là gì } else { string contentHistory = history.IDHistoryLearning + "#" + history.YearFrom + "#" + history.YearEnd + "#" + history.Address + "#" + history.IDStudent; File.AppendAllText(pathHistoryLearningDataFile, contentHistory + line); } } } }
/// <summary> /// Lấy sinh viên theo mã sinh viên từ mockdata /// </summary> /// <param name="IDStudent"></param> /// <returns>Lấy sinh viên theo mã sinh viên</returns> public static Student GetStudent(string idStudent) { Student student = new Student(); student.IDStudent = idStudent; student.FirstName = "Nhu"; student.LastName = "Quynh"; student.DOB = new DateTime(2019, 3, 5); student.POB = "QB"; student.Gender = Model.Gender.Male; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 1; i <= 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "THPT NTT", IDStudent = idStudent }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
/// <summary> /// Lấy danh sách lịch sử học tập của sinh viên /// </summary> /// <param name="pathHistoryLeaningFileName">Link file</param> /// <param name="idStudent"><Mã sinh viên</param> /// <returns></returns> public static List <HistoryLearning> getHistoryLearning(string pathHistoryLeaningFileName, string idStudent) { if (File.Exists(pathHistoryLeaningFileName)) { List <HistoryLearning> historyLearnings = new List <HistoryLearning>(); var lines = File.ReadAllLines(pathHistoryLeaningFileName); foreach (var line in lines) { if (!line.Equals("")) { var rs = line.Split(new char[] { '#' }); HistoryLearning historyLearning = new HistoryLearning { idHistoryLearning = rs[0], yearFrom = int.Parse(rs[1]), yearEnd = int.Parse(rs[2]), address = rs[3], idStudent = rs[4] }; if (historyLearning.idStudent == idStudent) { historyLearnings.Add(historyLearning); } } } return(historyLearnings); } else { return(null); } }
/// <summary> /// Lấy SV Theo mã SV từ MockData /// </summary> /// <param name="idStudent">Mã SV</param> /// <returns>SV có mã tương ứng hoặc null</returns> public static Student GetStudent(string idStudent) { Student student = new Student { IDStudent = idStudent, FirstName = "Nhi", LastName = "Lê", DOB = new DateTime(2000, 5, 5), POB = "Huế", Gender = GENDER.Female }; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 1; i <= 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = i.ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "THPT Hihihi", IDStudent = idStudent }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
public static Student GetStudent(string idStudent) { Student student = new Student { IDStudent = idStudent, FirstName = "Dung", LastName = "Nguyen", DOB = new DateTime(2000, 5, 5), POB = "Thua Thien Hue", Gender = GENDER.Male, }; student.ListHistoryLearning = new List <HistoryLearning>(); for (int i = 0; i < 12; i++) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = (i + 1).ToString(), YearFrom = 2006 + i, YearEnd = 2007 + i, Address = "THCS NTP", IDStudent = idStudent, }; student.ListHistoryLearning.Add(historyLearning); } return(student); }
public static void CreateHistoryLearningDB(HistoryLearning history) { var db = new AppG2Context(); history.IDHistoryLearning = Guid.NewGuid().ToString(); db.HistoryLearningDbset.Add(history); db.SaveChanges(); }
public static void addNewHistoryLearning(string pathHistoryLeaningFileName, int yearFrom, int yearEnd, string address, string idStudent) { // Lấy danh sách HistoryLearning trong file List <HistoryLearning> historyLearnings = new List <HistoryLearning>(); var lines = File.ReadAllLines(pathHistoryLeaningFileName); foreach (var line in lines) { var rs = line.Split(new char[] { '#' }); HistoryLearning historyLearning = new HistoryLearning { idHistoryLearning = rs[0], yearFrom = int.Parse(rs[1]), yearEnd = int.Parse(rs[2]), address = rs[3], idStudent = rs[4] }; historyLearnings.Add(historyLearning); } // Lấy id lớn nhất var maxId = 0; foreach (var his in historyLearnings) { if (Int32.Parse(his.idHistoryLearning) > maxId) { maxId = Int32.Parse(his.idHistoryLearning); } } // Tạo HistoryLearning mới var newHistoryLearning = new HistoryLearning(); newHistoryLearning.idHistoryLearning = (maxId + 1).ToString(); newHistoryLearning.yearFrom = yearFrom; newHistoryLearning.yearEnd = yearEnd; newHistoryLearning.address = address; newHistoryLearning.idStudent = idStudent; // Thêm HistoryLearning mới vào trong danh sách historyLearnings.Add(newHistoryLearning); // Ghi lại vào file List <string> lineWrites = new List <string>(); foreach (var history in historyLearnings) { string lineWrite = history.idHistoryLearning + "#" + history.yearFrom + "#" + history.yearEnd + "#" + history.address + "#" + history.idStudent; lineWrites.Add(lineWrite); } File.WriteAllLines(pathHistoryLeaningFileName, lineWrites); }
public static void EditHistoryLearningDB(HistoryLearning history) { var db = new AppG2Context(); var ht = db.HistoryLearningDbset.Find(history.IDHistoryLearning); ht.Address = history.Address; ht.YearFrom = history.YearFrom; ht.YearEnd = history.YearEnd; db.SaveChanges(); }
public static void CreateHistoryLearning(HistoryLearning history, string pathHistoryLearningDataFile) { if (File.Exists(pathHistoryLearningDataFile)) { string[] listLinesHistoryLearning = File.ReadAllLines(pathHistoryLearningDataFile); //Lấy file ra , nên dùng var cho an toàn history.IDHistoryLearning = Guid.NewGuid().ToString(); string contentHistory = history.IDHistoryLearning + "#" + history.YearFrom + "#" + history.YearEnd + "#" + history.Address + "#" + history.IDStudent; File.AppendAllText(pathHistoryLearningDataFile, "\n" + contentHistory); //Append là thêm vào, chèn vào sau chuỗi có trước, thêm vào ở File nào, nội dung là gì } }
/// <summary> /// Lay sinh vien theo ma sinh vien tu File /// </summary> /// <param name="pathDataFile">Duong dan toi file du lieu</param> /// <param name="idStudent">Ma sinh vien</param> /// <returns>Sinh vien co ma tuong ung hoac null</returns> public static Student GetStudent(string pathDataFile, string pathHistoryFile, string idStudent) { if (File.Exists(pathDataFile)) { CultureInfo culture = CultureInfo.InvariantCulture; // dinh dang ngay theo dinh dang tu quy dinh var listLines = File.ReadAllLines(pathDataFile); foreach (var line in listLines) { var rs = line.Split(new char[] { '#' }); Student student = new Student { IDStudent = rs[0], LastName = rs[1], FirstName = rs[2], Gender = rs[3] == "Male" ? GENDER.Male : (rs[3] == "Female" ? GENDER.Female : GENDER.Other), DOB = DateTime.ParseExact(rs[4], "yyyy-MM-dd", culture), POB = rs[5] }; if (student.IDStudent == idStudent) { #region Get History Learning if (File.Exists(pathHistoryFile)) { var listHistoryLines = File.ReadAllLines(pathHistoryFile); student.ListHistoryLearning = new List <HistoryLearning>(); foreach (var lineHistory in listHistoryLines) { var rsHistory = lineHistory.Split(new char[] { '#' }); if (rsHistory[4] == idStudent) { HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = rsHistory[0], YearFrom = Int32.Parse(rsHistory[1]), YearEnd = Int32.Parse(rsHistory[2]), Address = rsHistory[3], IDStudent = rsHistory[4] }; student.ListHistoryLearning.Add(historyLearning); } } } #endregion return(student); } } return(null); } else { return(null); } }
public frmQuatrinhHocTap(HistoryLearning history = null) { InitializeComponent(); this.history = history; if (history != null) { //chinh sua this.Text = "chinh sua qua trinh hoc tap"; numTunam.Value = history.YearFrom; numDennam.Value = history.YearFrom; txtNoihoc.Text = ""; } }
/// <summary> /// Lấy sinh viên theo MSV từ file /// </summary> /// <param name="pathDataFile">Đường dẫn tới file chứa dữ liệu</param> /// <param name="idStudent">Mã SV</param> /// <returns>SV hoặc null nếu không tồn tại</returns> public static Student GetStudent(string pathHistoryFile, string pathStudentFile, string idStudent) { if (File.Exists(pathStudentFile) && File.Exists(pathHistoryFile)) { CultureInfo culture = CultureInfo.InvariantCulture; //theo định dạng datetime mình tự quy định var listLines = File.ReadAllLines(pathStudentFile); var listHistory = File.ReadAllLines(pathHistoryFile); foreach (var line in listLines) { var rs = line.Split(new char[] { '#' }); //tách chuỗi ngăn bởi dấu # Student student = new Student { IDStudent = rs[0], LastName = rs[1], FirstName = rs[2], Gender = rs[3] == "Male" ? GENDER.Male : (rs[3] == "Female" ? GENDER.Female : GENDER.Other), DOB = DateTime.ParseExact(rs[4], "yyyy-MM-dd", culture), POB = rs[5] }; if (student.IDStudent == idStudent) { student.ListHistoryLearning = new List <HistoryLearning>(); foreach (var historyLine in listHistory) { var res = historyLine.Split(new char[] { '#' }); HistoryLearning historyLearning = new HistoryLearning { IDHistoryLearning = res[0], YearFrom = int.Parse(res[1]), YearEnd = int.Parse(res[2]), Address = res[3], IDStudent = res[4] }; if (student.IDStudent == historyLearning.IDStudent) { student.ListHistoryLearning.Add(historyLearning); } } return(student); } } return(null); } else { return(null); } }
/// <summary> /// Lấy sinh viên theo mã sinh viên từ file /// </summary> /// <param name="pathDataFile">Đường dẫn tới file chứa dữ liệu</param> /// <param name="idStudent">Mã sinh viên</param> /// <returns>Sinh viên theo mã sinh viên hoặc null nếu không tồn tại</returns> public static Student GetStudent(string pathDataFileStudent, string pathDataFileHistoryLearning, string idStudent) { if (File.Exists(pathDataFileStudent)) { CultureInfo cultureInfo = CultureInfo.InvariantCulture; // Dùng để parse ngày tháng string[] listLines = File.ReadAllLines(pathDataFileStudent); foreach (var line in listLines) { var rs = line.Split(new char[] { '#' }); Student student = new Student { IDStudent = rs[0], LastName = rs[1], FirstName = rs[2], Gender = rs[3] == "Male" ? Gender.Male : (rs[3] == "FeMale" ? Gender.FeMale : Gender.Other), DOB = DateTime.ParseExact(rs[4], "yyyy-MM-dd", cultureInfo), POB = rs[5] }; //History learning student.ListHistoryLearning = new List <HistoryLearning>(); if (File.Exists(pathDataFileHistoryLearning)) { string[] listLinesHistoryLearning = File.ReadAllLines(pathDataFileHistoryLearning); foreach (var lineHistory in listLinesHistoryLearning) { var ls = lineHistory.Split(new char[] { '#' }); HistoryLearning historyLearning = new HistoryLearning(); historyLearning.IDHistoryLearning = ls[0]; historyLearning.YearFrom = int.Parse(ls[1]); historyLearning.YearEnd = int.Parse(ls[2]); historyLearning.Address = ls[3]; historyLearning.IDStudent = ls[4]; if (student.IDStudent == historyLearning.IDStudent) { student.ListHistoryLearning.Add(historyLearning); } } } if (student.IDStudent == idStudent) { return(student); } } } return(null); }
public frmQuaTrinhHocTapChiTiet(HistoryLearning history = null) { InitializeComponent(); this.history = history; if (history != null) { this.Text = "Chỉnh sửa quá trình học tập"; numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; txtNoiHoc.Text = history.Address; } else { this.Text = "Thêm mới quá trình học tập"; } }
public Form1(HistoryLearning history = null) { InitializeComponent(); this.history = history; if (history != null) { //Chỉnh sửa this.Text = "Chỉnh sửa quá trình học tập"; numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; } else { //Thêm mới this.Text = "Thêm mới quá trình học tập"; } }
public frmQuaTrinhHocTap_ChiTiet(HistoryLearning history = null) { InitializeComponent(); this.history = history; if (history != null) { //Chỉnh sửa this.Text = "Chỉnh sửa quá trình học tập"; numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; txtHocTai.Text = history.SchoolName; } else { //Thêm mới this.Text = "Thêm mới quá trình học tập"; } }
public frmHistoryLearningDetail(string pathHistoryLeaningDataFile, string idStudent, HistoryLearning historyLearning = null) { InitializeComponent(); this.historyLearning = historyLearning; this.pathHistoryLeaningDataFile = pathHistoryLeaningDataFile; this.idStudent = idStudent; if (historyLearning != null) { // Chỉnh sửa quá trình học tập numTuNam.Value = historyLearning.yearFrom; numDenNam.Value = historyLearning.yearEnd; txtNoiHoc.Text = historyLearning.address; } else { // Thêm mới quá trình học tập } }
/// <summary> /// Lấy danh sách quá trình học tập của một sinh viên dựa vào idStudent /// </summary> /// <param name="idStudent">Mã sinh viên</param> /// <returns>Danh sách quá trình học tập của sinh viên</returns> public static List <HistoryLearning> GetListHistoryLearning(string idStudent) { List <HistoryLearning> histories = new List <HistoryLearning>(); for (int i = 1; i <= 12; i++) { HistoryLearning history = new HistoryLearning { ID = i.ToString(), YearFrom = 2000 + i, YearEnd = 2001 + i, SchoolName = "Phan Bội Châu", IDStudent = idStudent }; histories.Add(history); } return(histories); }
public frmQuaTrinhHocTapChiTiet(HistoryLearning history = null, string maSinhVien = null, string pathHistoryFile = null) { InitializeComponent(); this.history = history; this.maSinhVien = maSinhVien; this.pathHistoryFile = pathHistoryFile; if (history != null) { // Chỉnh sửa this.Text = "Chỉnh sửa QTHT"; numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; txtNoiHoc.Text = history.Address; } else { // Thêm mới this.Text = "Thêm mới QTHT"; } }
public frmQuaTrinhHocTapChiTiet(String idStudent, HistoryLearning history = null) { InitializeComponent(); pathHistoryLearningDataFile = Application.StartupPath + @"\Data\learninghistory.txt"; this.history = history; this.idStudent = idStudent; if (history != null) { //Chỉnh sửa this.Text = "Chỉnh sửa quá trình học tập"; numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; txtNguoiHoc.Text = history.Address; } else { //Thêm mới this.Text = "Thêm mới quá trình học tập"; } }
public frmQTHTChiTiet(string studentID, string pathHistoryFile, HistoryLearning history = null) { InitializeComponent(); this.history = history; this.studentID = studentID; this.pathHistoryFile = pathHistoryFile; if (history != null) { //chỉnh sửa this.Text = "Chỉnh sửa QTHT"; //tiêu đề numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; txtNoiHoc.Text = history.Address; } else { //Thêm mới this.Text = "Thêm mới QTHT"; } }
//string pathHistoryLearningDataFile = null; public frmQuaTrinhHocTapChiTiet(HistoryLearning history = null, string maSinhVien = null) { InitializeComponent(); this.history = history; //this.pathHistoryLearningDataFile = pathHistoryLearningDataFile; if (history != null) { //chinh sua this.Text = "Chỉnh sửa quá trình học tập"; numTuNam.Value = history.YearFrom; numDenNam.Value = history.YearEnd; txtNoiHoc.Text = history.Address; } else { //them moi this.Text = "Thêm quá trình học tập"; this.maSinhVien = maSinhVien; } }