F_RPT_020104.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_020104.cs
  5. * 2.功能描述:窑车状态表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/06/15 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Client.Controls;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.ReportModule;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. public partial class F_RPT_020104 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_020104 _instance;
  28. //默认窑炉选定值(清空按钮所用)
  29. private int _clearKilnValue = -1;
  30. // 当前选择的行
  31. private int _selectedRowIndex;
  32. #endregion
  33. #region 构造函数
  34. /// <summary>
  35. /// 构造函数
  36. /// </summary>
  37. public F_RPT_020104()
  38. {
  39. InitializeComponent();
  40. SetFromTitleInfo();//设置按钮文本
  41. }
  42. #endregion
  43. #region 单例模式
  44. /// <summary>
  45. /// 单例模式,防止重复创建窗体
  46. /// </summary>
  47. public static F_RPT_020104 Instance
  48. {
  49. get
  50. {
  51. if (_instance == null || _instance.IsDisposed)
  52. {
  53. _instance = new F_RPT_020104();
  54. }
  55. return _instance;
  56. }
  57. }
  58. #endregion
  59. #region 事件
  60. /// <summary>
  61. /// 窗体加载事件
  62. /// </summary>
  63. /// <param name="sender"></param>
  64. /// <param name="e"></param>
  65. private void F_RPT_020104_Load(object sender, EventArgs e)
  66. {
  67. try
  68. {
  69. // 设置表格不自动创建列
  70. this.dgvKilnCar.AutoGenerateColumns = false;
  71. this.dgvKilnCarDetail.AutoGenerateColumns = false;
  72. this.dgvKilnCarDetail.AutoGenerateColumns = false;
  73. // 加载权限
  74. FormPermissionManager.FormPermissionControl(this.Name, this,
  75. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  76. // 窑炉编码
  77. DataSet dsKiln = (DataSet)DoAsync(new AsyncMethod(() =>
  78. {
  79. return SystemModuleProxy.Service.GetKilnData(0);
  80. }));
  81. this.cmbKiln.DisplayMember = "KilnCode";
  82. this.cmbKiln.ValueMember = "KilnID";
  83. this.cmbKiln.DataSource = dsKiln.Tables[0];
  84. if (dsKiln.Tables[0].Rows.Count > 0)
  85. {
  86. this._clearKilnValue = Convert.ToInt32(dsKiln.Tables[0].Rows[0]["KilnID"]);
  87. }
  88. }
  89. catch (Exception ex)
  90. {
  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 tsbtnAdaptive_Click(object sender, EventArgs e)
  102. {
  103. this.dgvKilnCar.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  104. this.dgvKilnCarDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  105. this.dgvKilnCarGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  106. }
  107. /// <summary>
  108. /// 窗体关闭事件
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. private void F_RPT_020104_FormClosed(object sender, FormClosedEventArgs e)
  113. {
  114. _instance = null;
  115. }
  116. /// <summary>
  117. /// 关闭按钮事件
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. private void tsbtnClose_Click(object sender, EventArgs e)
  122. {
  123. this.Close();
  124. }
  125. /// <summary>
  126. /// 清空按钮事件
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void btnClearCondition_Click(object sender, EventArgs e)
  131. {
  132. this.txtKilnCarCode.Text = string.Empty;
  133. this.cmbKiln.SelectedValue = this._clearKilnValue;
  134. }
  135. /// <summary>
  136. /// 查询按钮事件
  137. /// </summary>
  138. /// <param name="sender"></param>
  139. /// <param name="e"></param>
  140. private void btnSearch_Click(object sender, EventArgs e)
  141. {
  142. try
  143. {
  144. //没有对应的生产线权限,返回 因为有无责任工序,则可以不用分配工序的权限,不分配,只能查无责任工序
  145. if (string.IsNullOrEmpty(this.cmbKiln.Text.Trim()))
  146. {
  147. MessageBox.Show("窑炉编码必须填写", this.Text,
  148. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  149. return;
  150. }
  151. this._selectedRowIndex = 0;
  152. // 记录当前选中行
  153. int selectRowIndex = this._selectedRowIndex;
  154. // 异步处理
  155. this.btnSearch.Enabled = false;
  156. this.btnClearCondition.Enabled = false;
  157. string KilnCode = this.cmbKiln.Text.Trim();
  158. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  159. {
  160. return ReportModuleProxy.Service.GetKilnCarStatusByCode(KilnCode, this.txtKilnCarCode.Text.Trim() == "" ? "" : KilnCode + this.txtKilnCarCode.Text.Trim());
  161. }));
  162. this.btnSearch.Enabled = true;
  163. this.btnClearCondition.Enabled = true;
  164. if (sre.Status == Constant.ServiceResultStatus.Success)
  165. {
  166. // 控制明细不查询
  167. this.Tag = false;
  168. this.dgvKilnCar.DataSource = sre.Data.Tables[0];
  169. this.dgvKilnCar.Rows[selectRowIndex].Selected = true;
  170. this.dgvKilnCar.CurrentCell = this.dgvKilnCar.Rows[selectRowIndex].Cells["kilncode1"];
  171. this.Tag = true;
  172. dgvKilnCar_SelectionChanged(null, null);
  173. this.dgvKilnCar.Focus();
  174. }
  175. else
  176. {
  177. // 提示未查找到数据
  178. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  179. MessageBoxButtons.OK, MessageBoxIcon.Information);
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. this.btnSearch.Enabled = true;
  185. this.btnClearCondition.Enabled = true;
  186. // 对异常进行共通处理
  187. ExceptionManager.HandleEventException(this.ToString(),
  188. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  189. }
  190. }
  191. /// <summary>
  192. /// 主表选定项发生改变时
  193. /// </summary>
  194. /// <param name="sender"></param>
  195. /// <param name="e"></param>
  196. private void dgvKilnCar_SelectionChanged(object sender, EventArgs e)
  197. {
  198. try
  199. {
  200. // 在绑定总表时 不查询明细
  201. if (!Convert.ToBoolean(this.Tag)
  202. || this.dgvKilnCar.CurrentCell == null)
  203. {
  204. return;
  205. }
  206. // 选中行时查询明细
  207. else
  208. {
  209. if (this.txtKilnCarCode.ReadOnly)
  210. {
  211. return;
  212. }
  213. //this.dgvKilnCar.Enabled = false;
  214. this._selectedRowIndex = this.dgvKilnCar.CurrentCell.RowIndex;
  215. this.dgvKilnCarDetail.DataSource = null;
  216. this.dgvKilnCarGoods.DataSource = null;
  217. string kilncarcode1 = this.dgvKilnCar.Rows[_selectedRowIndex].Cells["kilncarcode1"].Value.ToString();
  218. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  219. {
  220. return ReportModuleProxy.Service.GetKilnCarStatusDetailByCode(kilncarcode1);
  221. }));
  222. if (sre.Status == Constant.ServiceResultStatus.Success)
  223. {
  224. this.dgvKilnCarDetail.DataSource = sre.Data.Tables[0];
  225. this.dgvKilnCarGoods.DataSource = sre.Data.Tables[1];
  226. this.dgvKilnCar.Focus();
  227. }
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. // 对异常进行共通处理
  233. ExceptionManager.HandleEventException(this.ToString(),
  234. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  235. }
  236. finally
  237. {
  238. this.dgvKilnCar.Enabled = true;
  239. }
  240. }
  241. #endregion
  242. #region 私有方法
  243. /// <summary>
  244. /// 设置窗体按钮的文本信息
  245. /// </summary>
  246. private void SetFromTitleInfo()
  247. {
  248. this.Text = FormTitles.F_RPT_020104;
  249. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  250. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  251. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  252. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  253. //查询条件
  254. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  255. }
  256. #endregion
  257. }
  258. }