//點選資料時▼ private void DataGrid_1_SelectionChanged(object sender, SelectionChangedEventArgs e) {//點選資料時 Volunteer_Applicant v = this.DataGrid_1.SelectedItem as Volunteer_Applicant; if (v != null) { getsignup_Data(v.申請編號); } }
//判斷勾跟X的方法 private void getcheck_delete(List <int> A, List <int> D, Label AL, Label DL) { Volunteer_Applicant v = this.DataGrid_1.SelectedItem as Volunteer_Applicant; if (A.Count == 0) { A.Add(v.申請編號); AL.Content = A.Count.ToString(); for (int i = 0; i < A.Count; i += 1) { for (int j = 0; j < D.Count; j += 1) { if (A[i] == D[j]) { D.Remove(D[j]); DL.Content = D.Count.ToString(); } } } } else { bool ok_in = false; for (int i = 0; i < A.Count; i += 1) { ok_in = true; if (A[i] == v.申請編號) { A.Remove(A[i]); ok_in = false; AL.Content = A.Count.ToString(); DL.Content = D.Count.ToString(); break; } } if (ok_in) { A.Add(v.申請編號); D.Remove(v.申請編號); AL.Content = A.Count.ToString(); DL.Content = D.Count.ToString(); } } }
//按下確認▼ private void btn_check_Click(object sender, RoutedEventArgs e) { if (l_click_ok.Count != 0 || l_click_delete.Count != 0) //如果勾勾或XX集合內有值的話進入 { if (first) //如果是在初次審核的頁面 { getclick(l_click_ok, l_click_delete, "初次審核", stage_interview); this.Myentity.SaveChanges(); //將修改存回資料庫 this.DataGrid_1.ItemsSource = null; //更新該頁面 this.DataGrid_1.ItemsSource = get_volunteer(stage_first); //重新呼叫資料 } else if (interview || selection) //如果是在面試審核的頁面 { getclick(l_click_ok, l_click_delete, "面試審核", stage_pass_applicant); this.Myentity.SaveChanges(); //將修改存回資料庫 Inertgroup_andexpertise(l_click_ok); this.DataGrid_1.ItemsSource = null; //更新該頁面 this.DataGrid_1.ItemsSource = get_volunteer(stage_interview); //重新呼叫資料 } } else { if (((Button)e.Source).Content.ToString() == "刪除") //如果是審核通過頁面按下刪除鍵 { //秀出一個確認視窗 if (System.Windows.Forms.MessageBox.Show("確認刪除這筆資料?\n如果電子郵件欄位為空,就不會發送信件", "刪除確認", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { Volunteer_Applicant VA = this.DataGrid_1.SelectedItem as Volunteer_Applicant; var q = (from v in Myentity.Sign_up select v).ToList(); for (int i = 0; i < q.Count; i += 1) { if (VA.申請編號 == q[i].Sign_up_no) { //TODO刪除功能 this.Myentity.Sign_up.Remove(q[i]); //執行刪除的動作 ThreadStart TS = new ThreadStart( delegate() { sending_email(q[i].Email, q[i].Chinese_name + q[i].English_name, Issend_delete, "0"); //寄送郵件 System.Windows.Forms.Application.DoEvents(); }); send_mail = new Thread(TS); send_mail.IsBackground = true; send_mail.Start(); break; } } } } this.Myentity.SaveChanges(); //將修改存回資料庫 this.DataGrid_1.ItemsSource = null; //更新該頁面 if (pass_applicant) { this.DataGrid_1.ItemsSource = get_volunteer(stage_pass_applicant); //重新呼叫資料 } else { this.DataGrid_1.ItemsSource = get_volunteer(stage_reject); //重新呼叫資料 } } }