F_MST_0701.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0701.cs
  5. * 2.功能描述:报表数据来源
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/12/25 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.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. /// <summary>
  22. /// 报表数据来源
  23. /// </summary>
  24. public partial class F_MST_0701 : DockPanelBase
  25. {
  26. #region 成员变量
  27. //单例模式
  28. private static F_MST_0701 _instance;
  29. //实体类
  30. private RptProcedureEntity _rptProcedureEntity;
  31. #endregion
  32. #region 构造函数
  33. public F_MST_0701()
  34. {
  35. InitializeComponent();
  36. this.Text = FormTitles.F_MST_0701;
  37. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  38. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  39. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  40. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  41. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  42. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  43. this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
  44. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  45. }
  46. #endregion
  47. #region 单例模式
  48. /// <summary>
  49. /// 单例模式,防止重复创建窗体
  50. /// </summary>
  51. public static F_MST_0701 Instance
  52. {
  53. get
  54. {
  55. if (_instance == null)
  56. {
  57. _instance = new F_MST_0701();
  58. }
  59. return _instance;
  60. }
  61. }
  62. #endregion
  63. #region 事件
  64. /// <summary>
  65. /// 窗体加载
  66. /// </summary>
  67. private void F_MST_0701_Load(object sender, EventArgs e)
  68. {
  69. //绑定报表工序类型
  70. BindSelectData();
  71. this.dgvRptProcedure.AutoGenerateColumns = false;
  72. this.dgvRptSProcedure.AutoGenerateColumns = false;
  73. this.dgvRptTProcedure.AutoGenerateColumns = false;
  74. }
  75. /// <summary>
  76. /// 查询事件
  77. /// </summary>
  78. private void btnSearch_Click(object sender, EventArgs e)
  79. {
  80. try
  81. {
  82. //获取查询条件
  83. BindSelectedData();
  84. DataSet dsSearchRptProcedure = (DataSet)DoAsync(() =>
  85. {
  86. return SystemModuleProxy.Service.GetRptProcedureModule(_rptProcedureEntity);
  87. });
  88. if (dsSearchRptProcedure != null)
  89. {
  90. if (dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  91. {
  92. // 提示未查找到数据
  93. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  94. MessageBoxButtons.OK, MessageBoxIcon.Information);
  95. //清空数据
  96. this.dgvRptProcedure.DataSource = null;
  97. }
  98. else
  99. {
  100. this.dgvRptProcedure.DataSource = dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO];
  101. }
  102. }
  103. }
  104. catch (Exception ex)
  105. {
  106. // 对异常进行共通处理
  107. ExceptionManager.HandleEventException(this.ToString(),
  108. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  109. }
  110. }
  111. /// <summary>
  112. /// 清空事件
  113. /// </summary>
  114. private void btnClearCondition_Click(object sender, EventArgs e)
  115. {
  116. this.txtRptProcedureName.Text = string.Empty;
  117. }
  118. /// <summary>
  119. /// 关闭窗体事件
  120. /// </summary>
  121. private void tsbtnClose_Click(object sender, EventArgs e)
  122. {
  123. this.Close();
  124. }
  125. /// <summary>
  126. /// 自适应事件
  127. /// </summary>
  128. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  129. {
  130. this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  131. this.dgvRptSProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  132. this.dgvRptTProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  133. }
  134. /// <summary>
  135. /// 窗体关闭事件
  136. /// </summary>
  137. private void F_MST_0701_FormClosed(object sender, FormClosedEventArgs e)
  138. {
  139. _instance = null;
  140. }
  141. /// <summary>
  142. /// 添加事件
  143. /// </summary>
  144. private void tsbtnAdd_Click(object sender, EventArgs e)
  145. {
  146. try
  147. {
  148. //以新建模式打开信息窗体
  149. F_MST_0702 frmMST0702 = new F_MST_0702(Constant.FormMode.Add, Constant.INT_IS_ZERO);
  150. DialogResult dialogResult = frmMST0702.ShowDialog();
  151. if (dialogResult == DialogResult.OK)
  152. {
  153. btnSearch_Click(sender, e);
  154. }
  155. }
  156. catch (Exception ex)
  157. {
  158. // 对异常进行共通处理
  159. ExceptionManager.HandleEventException(this.ToString(),
  160. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  161. }
  162. }
  163. /// <summary>
  164. ///编辑事件
  165. /// </summary>
  166. private void tsbtnEdit_Click(object sender, EventArgs e)
  167. {
  168. try
  169. {
  170. DataGridViewRow currentRow = this.dgvRptProcedure.CurrentRow;
  171. if (currentRow != null)
  172. {
  173. //获取需要的信息ID
  174. int entityId = Convert.ToInt32(currentRow.Cells["RptProcedureID"].Value);
  175. //以复制模式打开信息窗体
  176. F_MST_0702 frmMST0702 = new F_MST_0702(Constant.FormMode.Edit, entityId);
  177. DialogResult dialogResult = frmMST0702.ShowDialog();
  178. //操作成功后刷新数据源
  179. if (dialogResult == DialogResult.OK)
  180. {
  181. btnSearch_Click(sender, e);
  182. }
  183. }
  184. }
  185. catch (Exception ex)
  186. {
  187. // 对异常进行共通处理
  188. ExceptionManager.HandleEventException(this.ToString(),
  189. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  190. }
  191. }
  192. /// <summary>
  193. /// 停用事件
  194. /// </summary>
  195. private void tsbtnDisable_Click(object sender, EventArgs e)
  196. {
  197. try
  198. {
  199. DataGridViewRow currentRow = this.dgvRptProcedure.CurrentRow;
  200. if (currentRow != null)
  201. {
  202. this._rptProcedureEntity = new RptProcedureEntity();
  203. //获取需要的信息ID
  204. this._rptProcedureEntity.RptProcedureID = Convert.ToInt32(currentRow.Cells["RptProcedureID"].Value);
  205. this._rptProcedureEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["OPTimeStamp"].Value);
  206. int resultCount = (int)DoAsync(() =>
  207. {
  208. return SystemModuleProxy.Service.StopRptProcedure(this._rptProcedureEntity);
  209. });
  210. if (resultCount > Constant.INT_IS_ZERO)
  211. {
  212. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "报表数据来源", "停用"),
  213. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  214. //获取条件
  215. BindSelectedData();
  216. //清空
  217. this.dgvRptProcedure.DataSource = null;
  218. DataSet dsSearchRptProcedure = (DataSet)DoAsync(new AsyncMethod(() =>
  219. {
  220. return SystemModuleProxy.Service.GetRptProcedureModule(_rptProcedureEntity);
  221. }));
  222. if (dsSearchRptProcedure != null)
  223. {
  224. if (dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  225. {
  226. // 提示未查找到数据
  227. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  228. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  229. //清空数据
  230. this.dgvRptProcedure.DataSource = null;
  231. }
  232. else
  233. {
  234. this.dgvRptProcedure.DataSource = dsSearchRptProcedure.Tables[Constant.INT_IS_ZERO];
  235. }
  236. }
  237. }
  238. else
  239. {
  240. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "报表数据来源", "停用"),
  241. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  242. }
  243. }
  244. }
  245. catch (Exception ex)
  246. {
  247. // 对异常进行共通处理
  248. ExceptionManager.HandleEventException(this.ToString(),
  249. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  250. }
  251. }
  252. /// <summary>
  253. /// 行选中事件
  254. /// </summary>
  255. private void dgvRptProcedure_SelectionChanged(object sender, EventArgs e)
  256. {
  257. if (this.dgvRptProcedure.SelectedRows.Count != Constant.INT_IS_ZERO)
  258. {
  259. DataGridViewRow gvrNow = this.dgvRptProcedure.SelectedRows[Constant.INT_IS_ZERO];
  260. if (gvrNow.Cells["RptProcedureID"].Value != DBNull.Value && gvrNow.Cells["RptProcedureID"].Value != null)
  261. {
  262. int rptProcedureId = Convert.ToInt32(gvrNow.Cells["RptProcedureID"].Value.ToString());
  263. DataSet dsSearchProcedure = SystemModuleProxy.Service.GetRptProcedureIdByProcedureInfo(rptProcedureId);
  264. if (dsSearchProcedure != null)
  265. {
  266. //绑定来源工序
  267. if (dsSearchProcedure.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  268. {
  269. // 提示未查找到数据
  270. //MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  271. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  272. //清空数据
  273. this.dgvRptSProcedure.DataSource = null;
  274. }
  275. else
  276. {
  277. this.dgvRptSProcedure.DataSource = dsSearchProcedure.Tables[Constant.INT_IS_ZERO];
  278. }
  279. //绑定统计工序
  280. if (dsSearchProcedure.Tables[Constant.INT_IS_ONE].Rows.Count <= Constant.INT_IS_ZERO)
  281. {
  282. // 提示未查找到数据
  283. //MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  284. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  285. //清空数据
  286. this.dgvRptTProcedure.DataSource = null;
  287. }
  288. else
  289. {
  290. this.dgvRptTProcedure.DataSource = dsSearchProcedure.Tables[Constant.INT_IS_ONE];
  291. }
  292. }
  293. }
  294. }
  295. }
  296. #endregion
  297. #region 私有方法
  298. /// <summary>
  299. /// 绑定数据来源类型
  300. /// </summary>
  301. private void BindSelectData()
  302. {
  303. DataTable newdtb = new DataTable();
  304. newdtb.Columns.Add("RptProcedureTypeId", typeof(string));
  305. newdtb.Columns.Add("RptProcedureType", typeof(string));
  306. DataRow newRow = newdtb.NewRow();
  307. newRow["RptProcedureTypeId"] = "A0001";
  308. newRow["RptProcedureType"] = "出窑统计";
  309. newdtb.Rows.Add(newRow);
  310. this.cobRptProcedureType.DisplayMember = "RptProcedureType";
  311. this.cobRptProcedureType.ValueMember = "RptProcedureTypeId";
  312. this.cobRptProcedureType.DataSource = newdtb;
  313. }
  314. /// <summary>
  315. /// 获取查询条件值
  316. /// </summary>
  317. private void BindSelectedData()
  318. {
  319. this._rptProcedureEntity = new RptProcedureEntity();
  320. this._rptProcedureEntity.RptProcedureName = this.txtRptProcedureName.Text.Trim();
  321. if (this.cobRptProcedureType.SelectedValue != null)
  322. {
  323. this._rptProcedureEntity.RptProcedureTpye = this.cobRptProcedureType.SelectedValue.ToString();
  324. }
  325. }
  326. #endregion
  327. }
  328. }