private void ExportLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string path = string.Empty; string msg = string.Empty; string exportMode = ExportCombo.SelectedItem.ToString(); DataTable dt = dataGridView1.DataSource as DataTable; if (dataGridView1.Rows.Count == 0) { MessageBox.Show("沒有資料", "錯誤訊息"); return; } SaveFileDialog sfd = new SaveFileDialog { Title = "請選擇存檔的路徑", FileName = "Excel", Filter = @"Excel|*.xlsx" }; if (sfd.ShowDialog() == DialogResult.Cancel) { return; } else { path = Path.GetDirectoryName(sfd.FileName); } var idList = (from row in dt.AsEnumerable() where !string.IsNullOrEmpty(row.Field <int?>("Contact_Id").ToString()) select row.Field <int?>("Contact_Id").ToString()).ToList(); switch (exportMode) { case "聯繫狀況": msg = TalentCommon.GetInstance().ExportContactSituationDataByContactId(idList, path); break; case "面談資料": msg = TalentCommon.GetInstance().ExportInterviewDataByContactId(idList, path); break; case "所有資料": msg = TalentCommon.GetInstance().ExportAllDataByContactId(idList, path); break; default: msg = "沒有匯出任何資料"; break; } MessageBox.Show(msg, "訊息"); }
private void ExportLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string path = string.Empty; string msg = string.Empty; string exportMode = ExportCombo.SelectedItem.ToString(); if (string.IsNullOrEmpty(Contact_Id)) { MessageBox.Show("沒有聯繫資料,請先儲存資料"); return; } SaveFileDialog sfd = new SaveFileDialog { Title = "請選擇存檔的路徑", FileName = "Excel", Filter = @"Excel|*.xlsx" }; if (sfd.ShowDialog() == DialogResult.Cancel) { return; } else { path = Path.GetDirectoryName(sfd.FileName); } List <string> idList = new List <string> { Contact_Id }; switch (exportMode) { case "聯繫狀況": msg = TalentCommon.GetInstance().ExportContactSituationDataByContactId(idList, path); break; case "面談資料": msg = TalentCommon.GetInstance().ExportInterviewDataByContactId(idList, path); break; case "所有資料": msg = TalentCommon.GetInstance().ExportAllDataByContactId(idList, path); break; default: msg = "沒有匯出任何資料"; break; } MessageBox.Show(msg, "訊息"); }
/// <summary> /// 根據動作執行"更改狀態"or"重設密碼"or"刪除帳號" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } ////重設密碼 if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("重設密碼")) { for (int i = 0; i < dataGridView2.ColumnCount; i++) { if (dataGridView2.Rows[e.RowIndex].Cells[i].Value.ToString().Contains("@")) { string msg = TalentCommon.GetInstance().AlertUpdatePassword(dataGridView2.Rows[e.RowIndex].Cells[i].Value.ToString()); if (!msg.Equals("寄送成功")) { MessageBox.Show(msg, "錯誤訊息"); } else { MessageBox.Show("密碼重設成功,請去信箱收信", "訊息"); } return; } } } ////刪除帳號 if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("刪除")) { DialogResult result = MessageBox.Show("即將刪除該帳號是否繼續?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { for (int i = 0; i < dataGridView2.ColumnCount; i++) { if (dataGridView2.Rows[e.RowIndex].Cells[i].Value.ToString().Contains("@")) { string msg = Talent.GetInstance().DelMemberByAccount(dataGridView2.Rows[e.RowIndex].Cells[i].Value.ToString()); if (!msg.Equals("刪除成功")) { MessageBox.Show(msg, "錯誤訊息"); } else { MessageBox.Show(msg, "訊息"); this.Manage_Accounts(Account); } } } } } }