You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

666 lines
26 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.Sql;
  11. using System.Data.SqlClient;
  12. using ManagementSystem.Utility;
  13. namespace ManagementSystem
  14. {
  15. public partial class AccountingJournalMaintain : Form
  16. {
  17. //程式內共用物件
  18. string strFrmStatus = ""; //表單狀態
  19. string strActiveUserID = ""; //取得登入作用的使用者帳號
  20. string strAccountingBookID = ""; //取得作用中的帳本
  21. SqlConnection sqlConn = UtilityClass.GetConn(MainForm.strAccountingBookID);
  22. SqlCommand sqlCmd = new SqlCommand();
  23. DataSet sdInsurance = new System.Data.DataSet();
  24. string strPKey = ""; //程式內的Key值
  25. string strKey = ""; //程式內加密的Key值
  26. int intStartCount = 0;
  27. public AccountingJournalMaintain()
  28. {
  29. InitializeComponent();
  30. }
  31. #region 自定義程式
  32. private void SetupStatus() //畫面載入設定
  33. {
  34. try
  35. {
  36. strActiveUserID = MainForm.strActiveUserID;
  37. strAccountingBookID = MainForm.strAccountingBookID;
  38. strKey = MainForm.strKey;
  39. if (MainForm.strKey == "")
  40. {
  41. //設定Toolbar初始狀態
  42. tsbAdd.Enabled = false;
  43. tsbSave.Enabled = false;
  44. tsbDelete.Enabled = false;
  45. }
  46. //設定畫面初始狀態
  47. StatusChange("NONE");
  48. }
  49. catch (Exception ex)
  50. {
  51. ErrorHandler.WriteErrorLog("AccountJournalMaintain.cs", ex);
  52. }
  53. }
  54. public void StatusChange(string strStatus) //變更主畫面狀態
  55. {
  56. switch (strStatus.ToUpper())
  57. {
  58. case "NONE":
  59. CleanForm();
  60. CleanToolbar();
  61. LockForm();
  62. dgvDataMaintain.AllowUserToAddRows = false;
  63. ((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "";
  64. strFrmStatus = "";
  65. tsbSearch.Enabled = true;
  66. intStartCount = dgvDataMaintain.Rows.Count;
  67. break;
  68. case "SEARCH":
  69. UnLockForm();
  70. dgvDataMaintain.DataSource = null;
  71. Application.DoEvents();
  72. tsbSearch.Visible = false;
  73. tsbAdd.Enabled = false;
  74. tsbEdit.Enabled = false;
  75. tsbDelete.Enabled = false;
  76. tsbReturn.Enabled = false;
  77. tsbOK.Visible = true;
  78. tsbCancel.Visible = true;
  79. ((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "搜尋";
  80. strFrmStatus = "SEARCH";
  81. break;
  82. case "ADD":
  83. UnLockForm();
  84. dgvDataMaintain.AllowUserToAddRows = false;
  85. ((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "新增";
  86. strFrmStatus = "ADD";
  87. break;
  88. case "MODIFY":
  89. UnLockForm();
  90. ((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "修改";
  91. strFrmStatus = "MODIFY";
  92. break;
  93. case "DEL":
  94. ((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "刪除";
  95. strFrmStatus = "DEL";
  96. break;
  97. }
  98. }
  99. private void CleanForm() //清除畫面
  100. {
  101. //設定畫面物件狀態
  102. //清除GridView
  103. cbAccountingYear.DataSource = UtilityClass.GetAccountingYears(5);
  104. cbAccountingYear.SelectedIndex = 0;
  105. dpAccStart.Text = DateTime.Now.Year.ToString() + "/1/1" ;
  106. dpAccEnd.Text = DateTime.Now.ToShortDateString();
  107. txtAccountingID.Text = "";
  108. txtAccSubName.Text = "";
  109. txtMemo.Text = "";
  110. Application.DoEvents();
  111. }
  112. private void CleanToolbar() //清除工具列
  113. {
  114. //設定Toolbar狀態
  115. tsbSearch.Visible = true;
  116. tsbSearch.Enabled = true;
  117. tsbAdd.Visible = true;
  118. tsbAdd.Enabled = true;
  119. tsbEdit.Visible = true;
  120. tsbEdit.Enabled = true;
  121. tsbDelete.Visible = true;
  122. tsbDelete.Enabled = true;
  123. tsbReturn.Visible = true;
  124. tsbReturn.Enabled = true;
  125. tsbSave.Visible = false;
  126. tsbOK.Visible = false;
  127. tsbCancel.Visible = false;
  128. }
  129. private void UnLockForm() //解除限制唯讀物件
  130. {
  131. cbAccountingYear.Enabled = true;
  132. txtAccountingID.ReadOnly = false;
  133. txtAccSubName.ReadOnly = false;
  134. txtMemo.ReadOnly = false;
  135. dpAccStart.Enabled = true;
  136. dpAccEnd.Enabled = true;
  137. }
  138. private void LockForm() //限制唯讀物件
  139. {
  140. cbAccountingYear.Enabled = false;
  141. txtAccountingID.ReadOnly = true;
  142. txtAccSubName.ReadOnly = true;
  143. txtMemo.ReadOnly = true;
  144. dpAccStart.Enabled = false;
  145. dpAccEnd.Enabled = false;
  146. }
  147. private void SetGridColor() //處理欄位間隔顏色的改變
  148. {
  149. string ColorKey = "";
  150. Color clRowColor = Color.White;
  151. foreach (DataGridViewRow drColor in dgvDataMaintain.Rows)
  152. {
  153. if (!string.IsNullOrEmpty(ColorKey))
  154. {
  155. if (ColorKey == drColor.Cells[1].Value.ToString())
  156. {
  157. drColor.DefaultCellStyle.BackColor = clRowColor;
  158. }
  159. else
  160. {
  161. if (clRowColor == Color.White)
  162. {
  163. clRowColor = Color.LightGray;
  164. }
  165. else
  166. {
  167. clRowColor = Color.White;
  168. }
  169. drColor.DefaultCellStyle.BackColor = clRowColor;
  170. }
  171. }
  172. ColorKey = drColor.Cells[1].Value.ToString();
  173. }
  174. }
  175. public bool UpdateAccount(DataSet dsRecordUpdate) //維護分錄
  176. {
  177. try
  178. {
  179. return true;
  180. }
  181. catch (Exception ex)
  182. {
  183. ErrorHandler.WriteErrorLog("AccountJournalMaintain.cs", ex);
  184. return false;
  185. }
  186. }
  187. public void GoEvent() //執行事件
  188. {
  189. try
  190. {
  191. StringBuilder strSQL = new StringBuilder("");
  192. string strDebit = "";
  193. string strCredit = "";
  194. //檢查查詢條件是否相符
  195. if (cbAccountingYear.SelectedValue.ToString() != dpAccStart.Value.Year.ToString())
  196. {
  197. MessageBox.Show("傳票日期選擇之年份應與會計年度相符", "提示");
  198. dpAccStart.Focus();
  199. return;
  200. }
  201. //查詢事件
  202. strSQL.Clear();
  203. strSQL.Append("Select * ");
  204. strSQL.Append("From OTB_FNC_AccountingJournal ");
  205. strSQL.Append("Where AccountingBookID ='" + strAccountingBookID + "'");
  206. strSQL.Append("And AccountingID in (Select AccountingID From OTB_FNC_AccountingJournal Where 1=1 ");
  207. if (cbAccountingYear.SelectedValue.ToString() != "") //會計年度
  208. {
  209. strSQL.Append(" And AccountingID like '" + cbAccountingYear.SelectedValue.ToString() + "%' ");
  210. }
  211. if (dpAccStart.Text.Trim() != "") //分錄日期區間
  212. {
  213. strSQL.Append(" And AccountingDate Between Convert(DateTime, '" + dpAccStart.Text.Trim() + " 00:00:00', 120) AND Convert(DateTime, '" + dpAccEnd.Text.Trim() + " 23:59:59', 120)");
  214. }
  215. if (txtAccountingID.Text.Trim() != "") //傳票編號
  216. {
  217. strSQL.Append(" And AccountingID like '" + txtAccountingID.Text.Trim() + "' ");
  218. }
  219. if (txtAccSubName.Text.Trim() != "") //科目名稱
  220. {
  221. strSQL.Append(" And AccountingSubName like '" + txtAccSubName.Text.Trim() + "' ");
  222. }
  223. if (txtMemo.Text.Trim() != "") //備註
  224. {
  225. strSQL.Append(" And Memo like '" + txtMemo.Text.Trim() + "' ");
  226. }
  227. strSQL.Append(")");
  228. strSQL.Append(" Order By AccountingID, AccountingOrder ");
  229. //進行查詢
  230. dgvDataMaintain.Rows.Clear();
  231. using(DataSet dsTemp = UtilityClass.GetSQLResult(strSQL.ToString()))
  232. {
  233. DataTable dtTemp = dsTemp.Tables["Result"];
  234. foreach (DataRow drAccounting in dtTemp.Rows)
  235. {
  236. DataGridViewRow dgvRow = new DataGridViewRow();
  237. dgvRow.CreateCells(dgvDataMaintain);
  238. dgvRow.Cells[1].Value = drAccounting["AccountingID"].ToString(); //傳票編號
  239. dgvRow.Cells[2].Value = DateTime.Parse(drAccounting["AccountingDate"].ToString()).ToShortDateString(); //傳票日期
  240. dgvRow.Cells[3].Value = drAccounting["AccountingSubID"].ToString(); //科目代號
  241. dgvRow.Cells[4].Value = drAccounting["AccountingSubName"].ToString(); //科目名稱
  242. dgvRow.Cells[5].Value = drAccounting["Memo"].ToString(); //摘要
  243. strDebit = UtilityClass.DecryptDES(drAccounting["Debit"].ToString(), strKey);
  244. strCredit = UtilityClass.DecryptDES(drAccounting["Credit"].ToString(), strKey);
  245. dgvRow.Cells[6].Value = UtilityClass.MarkNumber(strDebit); //借方金額
  246. dgvRow.Cells[7].Value = UtilityClass.MarkNumber(strCredit); //貸方金額
  247. dgvRow.Cells[8].Value = drAccounting["ProjectCName"].ToString(); //專案名稱
  248. dgvRow.Cells[9].Value = drAccounting["ProjectNumber"].ToString(); //專案代碼
  249. dgvDataMaintain.Rows.Add(dgvRow);
  250. }
  251. SetGridColor();
  252. //將資料移到最下面
  253. if (dgvDataMaintain.Rows.Count > 0)
  254. {
  255. dgvDataMaintain.CurrentCell = dgvDataMaintain.Rows[dtTemp.Rows.Count - 1].Cells[0];
  256. }
  257. }
  258. }
  259. catch (Exception ex)
  260. {
  261. ErrorHandler.WriteErrorLog("AccountJournalMaintain.cs", ex);
  262. }
  263. }
  264. private bool CheckSel() //確認是否有資料被勾選
  265. {
  266. foreach (DataGridViewRow row in dgvDataMaintain.Rows)
  267. {
  268. DataGridViewCheckBoxCell Selcell = (DataGridViewCheckBoxCell)row.Cells["cCheckedColumn"]; //選擇狀態列
  269. if (Selcell.Value != null)
  270. {
  271. if (Selcell.Value == Selcell.TrueValue)
  272. {
  273. return true;
  274. }
  275. }
  276. }
  277. return false;
  278. }
  279. private void ShowUpdateDate(string strGUID) // 呈現最新修改人
  280. {
  281. //排除空值
  282. if (strGUID.Trim() == "")
  283. {
  284. return;
  285. }
  286. if (strGUID == null)
  287. {
  288. return;
  289. }
  290. strPKey = strGUID;
  291. string strSQL = "Select ModifyDate, ModifyUser From OTB_FNC_AccountingJournal Where AccountingID = '" + strGUID + "' And AccountingBookID ='" + strAccountingBookID + "'";
  292. using (SqlDataAdapter sqlAdapter = new SqlDataAdapter())
  293. {
  294. //添加參數
  295. sqlAdapter.SelectCommand = new SqlCommand();
  296. sqlAdapter.SelectCommand.Connection = sqlConn;
  297. sqlAdapter.SelectCommand.CommandText = strSQL;
  298. if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
  299. {
  300. sqlConn.Open();
  301. }
  302. //進行查詢
  303. DataTable dtTemp = UtilityClass.GetSQLResult(strSQL).Tables["Result"];
  304. ((MainForm)ParentForm).SsStatus.Items["tsslModifyUser"].Text = dtTemp.Rows[0]["ModifyUser"].ToString().Trim();
  305. ((MainForm)ParentForm).SsStatus.Items["tsslModifyDate"].Text = dtTemp.Rows[0]["ModifyDate"].ToString().Trim();
  306. }
  307. }
  308. #endregion
  309. #region 事件觸發及問題處理
  310. private void AccountJournalMaintain_Load(object sender, EventArgs e)
  311. {
  312. SetupStatus();
  313. GoEvent();
  314. }
  315. private void tsbReturn_Click(object sender, EventArgs e)
  316. {
  317. string strDebit = "";
  318. string strCredit = "";
  319. string strSelectStatus = "";
  320. if (CheckSel())
  321. {
  322. StatusChange("MODIFY");
  323. AccountingEntries frmAdd = new AccountingEntries();
  324. frmAdd.strFrmStatus = "ADD";
  325. frmAdd.Owner = this;
  326. frmAdd.strOwnerForm = this.Name + "_Reversal";
  327. frmAdd.strPKey = strPKey;
  328. frmAdd.StartPosition = FormStartPosition.CenterParent;
  329. //分錄產生
  330. foreach (DataGridViewRow row in dgvDataMaintain.Rows)
  331. {
  332. DataGridViewCheckBoxCell Selcell = (DataGridViewCheckBoxCell)row.Cells["cCheckedColumn"]; //選擇狀態列
  333. strSelectStatus = Selcell.Value.ToString();
  334. if (strSelectStatus != "False") //確認該分錄被選擇
  335. {
  336. strDebit = (string)row.Cells["cDebit"].Value;
  337. strCredit = (string)row.Cells["cCredit"].Value;
  338. DataGridViewRow dgvRow = new DataGridViewRow();
  339. dgvRow.CreateCells(frmAdd.dgvDataMaintain);
  340. dgvRow.Cells[1].Value = (string)row.Cells["cAccountSubID"].Value;
  341. dgvRow.Cells[2].Value = (string)row.Cells["cAccountSubName"].Value;
  342. dgvRow.Cells[3].Value = "傳票編號:" + (string)row.Cells["cAccountingID"].Value + "沖銷分錄";
  343. if (!string.IsNullOrEmpty(strDebit))
  344. {
  345. dgvRow.Cells[5].Value = strDebit;
  346. }
  347. else
  348. {
  349. dgvRow.Cells[4].Value = strCredit;
  350. }
  351. frmAdd.dgvDataMaintain.Rows.Add(dgvRow);
  352. }
  353. }
  354. frmAdd.ShowDialog();
  355. }
  356. else
  357. {
  358. MessageBox.Show("請先選擇要沖銷的分錄!", "提示");
  359. }
  360. }
  361. private void tsbExit_Click(object sender, EventArgs e)
  362. {
  363. this.Close();
  364. }
  365. private void tsbAdd_Click(object sender, EventArgs e)
  366. {
  367. StatusChange("ADD");
  368. tsbSearch.Enabled = false;
  369. tsbEdit.Enabled = false;
  370. tsbDelete.Enabled = false;
  371. tsbReturn.Enabled = false;
  372. AccountingEntries frmAdd = new AccountingEntries();
  373. frmAdd.strFrmStatus = "ADD";
  374. frmAdd.strOwnerForm = this.Name.ToString();
  375. frmAdd.Owner = this;
  376. frmAdd.StartPosition = FormStartPosition.CenterParent;
  377. frmAdd.ShowDialog();
  378. }
  379. private void tsbEdit_Click(object sender, EventArgs e)
  380. {
  381. if (CheckSel())
  382. {
  383. StatusChange("MODIFY");
  384. tsbEdit.Visible = false;
  385. tsbSearch.Enabled = false;
  386. tsbAdd.Enabled = false;
  387. tsbDelete.Enabled = false;
  388. tsbReturn.Enabled = false;
  389. AccountingEntries frmMdf = new AccountingEntries();
  390. frmMdf.strFrmStatus = "MODIFY";
  391. frmMdf.strOwnerForm = this.Name.ToString();
  392. frmMdf.Owner = this;
  393. frmMdf.strPKey = strPKey;
  394. frmMdf.StartPosition = FormStartPosition.CenterParent;
  395. frmMdf.ShowDialog();
  396. }
  397. else
  398. {
  399. MessageBox.Show("請先選擇要修改的資料!","提示");
  400. }
  401. }
  402. private void tsbDelete_Click(object sender, EventArgs e)
  403. {
  404. if (CheckSel())
  405. {
  406. StatusChange("DEL");
  407. tsbDelete.Visible = false;
  408. tsbEdit.Enabled = false;
  409. tsbSearch.Enabled = false;
  410. tsbAdd.Enabled = false;
  411. tsbReturn.Enabled = false;
  412. AccountingEntries frmAdd = new AccountingEntries();
  413. frmAdd.strFrmStatus = "DEL";
  414. frmAdd.Owner = this;
  415. frmAdd.strPKey = strPKey;
  416. frmAdd.StartPosition = FormStartPosition.CenterParent;
  417. frmAdd.ShowDialog();
  418. }
  419. else
  420. {
  421. MessageBox.Show("請先選擇要刪除的資料!", "提示");
  422. }
  423. }
  424. private void tsbSearch_Click(object sender, EventArgs e)
  425. {
  426. StatusChange("SEARCH");
  427. }
  428. private void tsbOK_Click(object sender, EventArgs e)
  429. {
  430. GoEvent();
  431. CleanToolbar();
  432. }
  433. private void tsbCancel_Click(object sender, EventArgs e)
  434. {
  435. CleanToolbar();
  436. StatusChange("NONE");
  437. }
  438. private void dgvDataMaintain_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) //製作合併儲存格的效果
  439. {
  440. try
  441. {
  442. Brush gridBrush = new SolidBrush(this.dgvDataMaintain.GridColor);
  443. SolidBrush backBrush = new SolidBrush(e.CellStyle.BackColor);
  444. SolidBrush fontBrush = new SolidBrush(e.CellStyle.ForeColor);
  445. int cellheight;
  446. int fontheight;
  447. int cellwidth;
  448. int fontwidth;
  449. int countU = 0;
  450. int countD = 0;
  451. int count = 0;
  452. #region 對第二列相同儲存格進行合併
  453. if (e.RowIndex != -1)
  454. {
  455. if (e.ColumnIndex == 1) //傳票編號欄位合併
  456. {
  457. cellheight = e.CellBounds.Height;
  458. fontheight = (int)e.Graphics.MeasureString(e.Value.ToString(), e.CellStyle.Font).Height;
  459. cellwidth = e.CellBounds.Width;
  460. fontwidth = (int)e.Graphics.MeasureString(e.Value.ToString(), e.CellStyle.Font).Width;
  461. Pen gridLinePen = new Pen(gridBrush);
  462. string curValue = e.Value == null ? "" : e.Value.ToString().Trim();
  463. string curSelected = this.dgvDataMaintain.Rows[e.RowIndex].Cells[1].Value == null ? "" : this.dgvDataMaintain.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Trim();
  464. if (!string.IsNullOrEmpty(curValue))
  465. {
  466. for (int intCount = e.RowIndex; intCount < this.dgvDataMaintain.Rows.Count; intCount++)
  467. {
  468. if (this.dgvDataMaintain.Rows[intCount].Cells[e.ColumnIndex].Value.ToString().Equals(curValue))
  469. {
  470. this.dgvDataMaintain.Rows[intCount].Cells[e.ColumnIndex].Selected = this.dgvDataMaintain.Rows[e.RowIndex].Selected;
  471. this.dgvDataMaintain.Rows[intCount].Selected = this.dgvDataMaintain.Rows[e.RowIndex].Selected;
  472. countD++;
  473. }
  474. else
  475. {
  476. break;
  477. }
  478. }
  479. for (int intCount = e.RowIndex; intCount >= 0; intCount--)
  480. {
  481. if (this.dgvDataMaintain.Rows[intCount].Cells[e.ColumnIndex].Value.ToString().Equals(curValue))
  482. {
  483. this.dgvDataMaintain.Rows[intCount].Cells[e.ColumnIndex].Selected = this.dgvDataMaintain.Rows[e.RowIndex].Selected;
  484. this.dgvDataMaintain.Rows[intCount].Selected = this.dgvDataMaintain.Rows[e.RowIndex].Selected;
  485. countU++;
  486. }
  487. else
  488. {
  489. break;
  490. }
  491. }
  492. count = countD + countU - 1;
  493. if (count < 2) { return; }
  494. }
  495. if (this.dgvDataMaintain.Rows[e.RowIndex].Selected)
  496. {
  497. backBrush.Color = e.CellStyle.SelectionBackColor;
  498. fontBrush.Color = e.CellStyle.SelectionForeColor;
  499. }
  500. e.Graphics.FillRectangle(backBrush, e.CellBounds);
  501. e.Graphics.DrawString((String)e.Value, e.CellStyle.Font, fontBrush, e.CellBounds.X + (cellwidth - fontwidth) / 2, e.CellBounds.Y - cellheight * (countU - 1) + (cellheight * count - fontheight) / 2);
  502. if (countD == 1)
  503. {
  504. e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, e.CellBounds.Bottom - 1);
  505. count = 0;
  506. }
  507. //畫右邊的線
  508. e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, e.CellBounds.Top, e.CellBounds.Right - 1, e.CellBounds.Bottom);
  509. e.Handled = true;
  510. }
  511. }
  512. #endregion
  513. }
  514. catch (Exception ex)
  515. {
  516. ErrorHandler.WriteErrorLog("AccountJournalMaintain.cs", ex);
  517. }
  518. }
  519. private void dgvDataMaintain_CellContentClick(object sender, DataGridViewCellEventArgs e) //CheckBox被選取處理事件
  520. {
  521. //當GridView中的Button被按下
  522. var SenderGrid = (DataGridView)sender;
  523. if (SenderGrid.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn && e.RowIndex >= 0)
  524. {
  525. foreach (DataGridViewRow dgRow in SenderGrid.Rows)
  526. {
  527. dgRow.Cells["cCheckedColumn"].Value = false;
  528. }
  529. foreach (DataGridViewRow dgRow in SenderGrid.Rows)
  530. {
  531. if (dgRow.Cells[1].Value.ToString() == SenderGrid.Rows[e.RowIndex].Cells[1].Value.ToString())
  532. {
  533. dgRow.Cells[0].Value = true;
  534. strPKey = SenderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
  535. }
  536. else
  537. {
  538. dgRow.Cells[0].Value = false;
  539. }
  540. }
  541. }
  542. }
  543. private void dgvDataMaintain_CellValueChanged(object sender, DataGridViewCellEventArgs e) //設定選取項目
  544. {
  545. if (dgvDataMaintain.CurrentRow != null)
  546. {
  547. DataGridViewCheckBoxCell Selcell = (DataGridViewCheckBoxCell)dgvDataMaintain.CurrentRow.Cells["cCheckedColumn"];
  548. Selcell.Value = Selcell.TrueValue;
  549. }
  550. }
  551. private void tsbClean_Click(object sender, EventArgs e)
  552. {
  553. CleanForm();
  554. }
  555. private void dgvDataMaintain_CellClick(object sender, DataGridViewCellEventArgs e)
  556. {
  557. ShowUpdateDate(dgvDataMaintain.CurrentRow.Cells["cAccountingID"].Value.ToString()); //顯示最新修改資料
  558. }
  559. private void dgvDataMaintain_CellEnter(object sender, DataGridViewCellEventArgs e)
  560. {
  561. ShowUpdateDate(dgvDataMaintain.CurrentRow.Cells["cAccountingID"].Value.ToString()); //顯示最新修改資料
  562. }
  563. private void cbAccountingYear_SelectedIndexChanged(object sender, EventArgs e)
  564. {
  565. if (cbAccountingYear.SelectedValue.ToString() == DateTime.Now.Year.ToString())
  566. {
  567. dpAccStart.Text = DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/1";
  568. dpAccEnd.Text = DateTime.Now.ToShortDateString();
  569. }
  570. else
  571. {
  572. dpAccStart.Text = cbAccountingYear.SelectedValue.ToString() + "/1/1";
  573. dpAccEnd.Text = cbAccountingYear.SelectedValue.ToString() + "/12/31";
  574. }
  575. }
  576. #endregion
  577. }
  578. }