9844510ba071bb78aa2d9bee474aa750bfbff257.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace FPER
  9. {
  10. public partial class frmModalPositionCode : Form
  11. {
  12. public frmModalPositionCode()
  13. {
  14. InitializeComponent();
  15. }
  16. MDIParent mdi = null;
  17. public void setMdiParent(MDIParent mdi)
  18. {
  19. try
  20. {
  21. this.mdi = mdi;
  22. }
  23. catch (Exception ex)
  24. {
  25. Util.UErrorMessage(ex, 0, 0);
  26. }
  27. }
  28. private SearchCodeVo searchCode;
  29. public SearchCodeVo SearchCode { get { return this.searchCode; } set { this.searchCode = value; } }
  30. private void frmModalPositionCode_Load(object sender, EventArgs e)
  31. {
  32. try
  33. {
  34. dataGridView1.Rows.Clear();
  35. if (searchCode.CodeType != null)
  36. {
  37. if (searchCode.CodeType.Length < 1) searchCode.CodeType = null;
  38. }
  39. if (searchCode.CodeName != null)
  40. {
  41. if (searchCode.CodeName.Length < 1) searchCode.CodeName = null;
  42. }
  43. txtSearchKey.Text = searchCode.CodeName;
  44. get_Data(null);
  45. }
  46. catch (Exception ex)
  47. {
  48. Util.UErrorMessage(ex, 0, 0);
  49. }
  50. }
  51. private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
  52. {
  53. try
  54. {
  55. //셀 더블클릭시
  56. if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
  57. {
  58. string CodeValue = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
  59. string CodeName = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
  60. this.searchCode.Code = CodeValue;
  61. this.searchCode.CodeName = CodeName;
  62. this.searchCode.SearchOK = true;
  63. this.Close();
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. Util.UErrorMessage(ex, 0, 0);
  69. }
  70. }
  71. private void btnOK_Click(object sender, EventArgs e)
  72. {
  73. try
  74. {
  75. String searchKey = txtSearchKey.Text;
  76. //if (searchKey.Length < 1)
  77. //{
  78. // MessageBox.Show("먼저 검색할 단어를 입력하세요.", Application.ProductName);
  79. // return;
  80. //}
  81. if (searchKey.Equals("")) searchKey = null;
  82. get_Data(searchKey);
  83. }
  84. catch (Exception ex)
  85. {
  86. Util.UErrorMessage(ex, 0, 0);
  87. }
  88. }
  89. private void get_Data(String SearchKey)
  90. {
  91. dataGridView1.Rows.Clear();
  92. try
  93. {
  94. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  95. DataTable dtable = dacDeviceConfig.Position_Code_Modal_Select(SearchKey);
  96. if (dtable.Rows.Count > 0)
  97. {
  98. foreach (DataRow dr in dtable.Rows)
  99. {
  100. dataGridView1.Rows.Add(dr["POSITION_CODE"].ToString(), dr["POSITION_NAME"].ToString());
  101. }
  102. }
  103. }
  104. catch (Exception ex)
  105. {
  106. Util.UErrorMessage(ex, 0, 0);
  107. //MessageBox.Show(ex.Message, Application.ProductName);
  108. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  109. }
  110. }
  111. private void txtSearchKey_KeyDown(object sender, KeyEventArgs e)
  112. {
  113. try
  114. {
  115. //엔터키 입력시 확인버튼으로 포커스
  116. if (e.KeyCode == Keys.Enter)
  117. {
  118. btnOK_Click(btnOK, EventArgs.Empty);
  119. }
  120. }
  121. catch (Exception ex)
  122. {
  123. Util.UErrorMessage(ex, 0, 0);
  124. }
  125. }
  126. private void btnCancel_Click(object sender, EventArgs e)
  127. {
  128. try
  129. {
  130. this.Close();
  131. }
  132. catch (Exception ex)
  133. {
  134. Util.UErrorMessage(ex, 0, 0);
  135. }
  136. }
  137. private void btnSaveOK_Click(object sender, EventArgs e)
  138. {
  139. try
  140. {
  141. if (dataGridView1.SelectedRows.Count > 0)
  142. {
  143. DataGridViewRow row = dataGridView1.SelectedRows[0];
  144. string CodeValue = row.Cells[0].Value.ToString();
  145. string CodeName = row.Cells[1].Value.ToString();
  146. this.searchCode.Code = CodeValue;
  147. this.searchCode.CodeName = CodeName;
  148. this.searchCode.SearchOK = true;
  149. this.Close();
  150. }
  151. else
  152. {
  153. MessageBox.Show("선택된 코드가 없습니다.", Application.ProductName);
  154. return;
  155. }
  156. }
  157. catch (Exception ex)
  158. {
  159. Util.UErrorMessage(ex, 0, 0);
  160. }
  161. }
  162. private void btnPositionAdd_Click(object sender, EventArgs e)
  163. {
  164. try
  165. {
  166. this.Close();
  167. this.mdi.ShowChildForm(new frmPositionCode());
  168. }
  169. catch (Exception ex)
  170. {
  171. Util.UErrorMessage(ex, 0, 0);
  172. }
  173. }
  174. }
  175. }