F_PC_0601.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_0601.cs
  5. * 2.功能描述:员工关联
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/04/17 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PCModule
  22. {
  23. /// <summary>
  24. /// 员工关联
  25. /// </summary>
  26. public partial class F_PC_0601 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. // 单例模式
  30. private static F_PC_0601 _instance;
  31. // 正在查询
  32. private bool _isSearching = false;
  33. #endregion
  34. #region 构造函数
  35. public F_PC_0601()
  36. {
  37. InitializeComponent();
  38. this.Text = FormTitles.F_PC_0601;
  39. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  40. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  41. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  42. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  43. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  44. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  45. }
  46. #endregion
  47. #region 单例模式
  48. /// <summary>
  49. /// 单例模式,防止重复创建窗体
  50. /// </summary>
  51. public static F_PC_0601 Instance
  52. {
  53. get
  54. {
  55. if (_instance == null)
  56. {
  57. _instance = new F_PC_0601();
  58. }
  59. return _instance;
  60. }
  61. }
  62. #endregion
  63. #region 事件
  64. /// <summary>
  65. /// 搜索按钮事件
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void btnSearch_Click(object sender, EventArgs e)
  70. {
  71. try
  72. {
  73. this._isSearching = true;
  74. this.dgvUser.DataSource = null;
  75. this.dgvStaff.DataSource = null;
  76. this.DataSource = this.GetSearchData();
  77. if (this.DataSource != null)
  78. {
  79. this.dgvUser.DataSource = this.DataSource.Tables[0];
  80. if (this.DataSource.Tables.Count > 1)
  81. {
  82. this.dgvStaff.DataSource = this.DataSource.Tables[1];
  83. }
  84. }
  85. this._isSearching = false;
  86. }
  87. catch (Exception ex)
  88. {
  89. this.btnSearch.Enabled = true;
  90. this.btnClearCondition.Enabled = true;
  91. // 对异常进行共通处理
  92. ExceptionManager.HandleEventException(this.ToString(),
  93. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  94. }
  95. }
  96. /// <summary>
  97. /// 清空按钮事件
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void btnClearCondition_Click(object sender, EventArgs e)
  102. {
  103. this.txtUserCode.Clear();
  104. this.txtRemarks.Clear();
  105. }
  106. /// <summary>
  107. /// 选定项改变事件
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. private void dgvUser_SelectionChanged(object sender, EventArgs e)
  112. {
  113. if (this._isSearching)
  114. {
  115. return;
  116. }
  117. try
  118. {
  119. DataGridViewRow currentRow = this.dgvUser.CurrentRow;
  120. if (currentRow != null)
  121. {
  122. int id = Convert.ToInt32(currentRow.Cells["userid"].Value);
  123. this.dgvStaff.DataSource = null;
  124. // 调用服务器端获取数据集
  125. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  126. {
  127. return PCModuleProxyNew.Service.GetFPC0601SNData(id);
  128. }
  129. );
  130. if (sre.Status == Constant.ServiceResultStatus.Success)
  131. {
  132. this.dgvStaff.DataSource = sre.Data.Tables[0];
  133. }
  134. }
  135. else
  136. {
  137. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  138. }
  139. }
  140. catch (Exception ex)
  141. {
  142. // 对异常进行共通处理
  143. ExceptionManager.HandleEventException(this.ToString(),
  144. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  145. }
  146. }
  147. /// <summary>
  148. /// 新增按钮事件
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void tsbtnAddUser_Click(object sender, EventArgs e)
  153. {
  154. try
  155. {
  156. F_PC_0602 frmFPC0602 = new F_PC_0602(null, null);
  157. DialogResult dialogresult = frmFPC0602.ShowDialog();
  158. }
  159. catch (Exception ex)
  160. {
  161. // 对异常进行共通处理
  162. ExceptionManager.HandleEventException(this.ToString(),
  163. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  164. }
  165. }
  166. /// <summary>
  167. /// 单元格双击事件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void dgvUser_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  172. {
  173. if (e.RowIndex < 0 || e.ColumnIndex < 0)
  174. {
  175. return;
  176. }
  177. this.tsbtnEditUser_Click(sender, e);
  178. }
  179. /// <summary>
  180. /// 编辑按钮事件
  181. /// </summary>
  182. /// <param name="sender"></param>
  183. /// <param name="e"></param>
  184. private void tsbtnEditUser_Click(object sender, EventArgs e)
  185. {
  186. try
  187. {
  188. if (this.dgvUser.SelectedRows.Count != 0)
  189. {
  190. string userId = this.dgvUser.SelectedRows[0].Cells["userId"].Value.ToString();
  191. string userCode = this.dgvUser.SelectedRows[0].Cells["userCode"].Value.ToString();
  192. F_PC_0602 frmFPC0602 = new F_PC_0602(Convert.ToInt32(userId), userCode);
  193. DialogResult dialogresult = frmFPC0602.ShowDialog();
  194. }
  195. }
  196. catch (Exception ex)
  197. {
  198. // 对异常进行共通处理
  199. ExceptionManager.HandleEventException(this.ToString(),
  200. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  201. }
  202. }
  203. /// <summary>
  204. /// 窗体加载事件
  205. /// </summary>
  206. /// <param name="sender"></param>
  207. /// <param name="e"></param>
  208. private void F_PC_0601_Load(object sender, EventArgs e)
  209. { // 按钮权限控制
  210. FormPermissionManager.FormPermissionControl(this.Name, this,
  211. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  212. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  213. }
  214. /// <summary>
  215. /// 自适应列宽
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  220. {
  221. this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  222. }
  223. /// <summary>
  224. /// 关闭按钮事件
  225. /// </summary>
  226. /// <param name="sender"></param>
  227. /// <param name="e"></param>
  228. private void tsbtnClose_Click(object sender, EventArgs e)
  229. {
  230. this.Close();
  231. }
  232. /// <summary>
  233. /// 释放窗体
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. private void F_PC_0601_FormClosed(object sender, FormClosedEventArgs e)
  238. {
  239. _instance = null;
  240. }
  241. #endregion
  242. #region 私有方法
  243. /// <summary>
  244. /// 根据界面查询条件获取数据集
  245. /// </summary>
  246. private DataSet GetSearchData()
  247. {
  248. try
  249. {
  250. FPC0601_SE se = new FPC0601_SE();
  251. se.UserCode = this.txtUserCode.Text;
  252. se.Remarks = this.txtRemarks.Text;
  253. // 调用服务器端获取数据集
  254. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  255. {
  256. return PCModuleProxyNew.Service.GetFPC0601SData(se);
  257. }
  258. );
  259. if (sre.Status == Constant.ServiceResultStatus.Success)
  260. {
  261. return sre.Data;
  262. }
  263. return null;
  264. }
  265. catch (Exception ex)
  266. {
  267. throw ex;
  268. }
  269. }
  270. #endregion
  271. }
  272. }