private void BGW_DoWork(object sender, DoWorkEventArgs e) { StringBuilder sb_sql = new StringBuilder(); sb_sql.Append("select student.id as student_id,student.name as student_name,student.student_number,"); sb_sql.Append("student.seat_no,class.class_name,class.grade_year,parent.relationship,"); sb_sql.Append("parent.account as parent_account,student.student_code,student.parent_code,"); sb_sql.Append("sa_login_name,student.father_name,student.mother_name,student.custodian_name "); sb_sql.Append("from student "); sb_sql.Append("left join student_parent parent on student.id=parent.ref_student_id "); sb_sql.Append("left join class on class.id=student.ref_class_id "); sb_sql.Append("where account is not null "); //當使用者輸入條件時 if (searchText != "") { sb_sql.Append(string.Format("and (student.name like '%{0}%' or student.student_number like '%{0}%' or ", searchText)); sb_sql.Append(string.Format("parent.account like '%{0}%' or student.student_code like '%{0}%' or student.parent_code like '%{0}%' or ", searchText)); sb_sql.Append(string.Format("student.sa_login_name like '%{0}%' or student.father_name like '%{0}%' or ", searchText)); sb_sql.Append(string.Format("student.mother_name like '%{0}%' or student.custodian_name like '%{0}%') ", searchText)); } sb_sql.Append("order by class.grade_year,class.display_order,class.grade_year,student.seat_no,student.name"); //取得學生代碼家長代碼 student - parent_code student_code DataTable dt = tool._Q.Select(sb_sql.ToString()); studList = new List <Stud>(); foreach (DataRow row in dt.Rows) { Stud stud = new Stud(row); studList.Add(stud); } }
public ParentEdit(Stud stud) { InitializeComponent(); _stud = stud; }