F_MST_1301.cs 8.0 KB

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