F_RPT_030115.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030115.cs
  5. * 2.功能描述:废品损失汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2016/07/12 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.PMModuleService;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  20. using Dongke.IBOSS.PRD.Client.Controls;
  21. using System.Collections.Generic;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. /// <summary>
  25. /// 废品损失汇总表
  26. /// </summary>
  27. public partial class F_RPT_030115 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. //单例模式
  31. private static F_RPT_030115 _instance;
  32. #endregion
  33. #region 构造函数
  34. /// <summary>
  35. /// 废弃一览构造
  36. /// </summary>
  37. public F_RPT_030115()
  38. {
  39. InitializeComponent();
  40. this.Text = "废品损失汇总表";
  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_RPT_030115 Instance
  52. {
  53. get
  54. {
  55. if (_instance == null)
  56. {
  57. _instance = new F_RPT_030115();
  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. //object value = this.cboPT.SelectedValue;
  74. //if (value == null || value == DBNull.Value)
  75. //{
  76. // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工序配置"), this.Text,
  77. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  78. //}
  79. // 汇总表
  80. if (this.tabControl1.SelectedIndex == 0)
  81. {
  82. this.dgvSemi.DataSource = null;
  83. List<DataGridViewTextBoxColumn> cols = new List<DataGridViewTextBoxColumn>();
  84. foreach (DataGridViewTextBoxColumn item in dgvSemi.Columns)
  85. {
  86. if (item != null && item.Tag != null)
  87. {
  88. cols.Add(item);
  89. }
  90. }
  91. foreach (DataGridViewTextBoxColumn item in cols)
  92. {
  93. dgvSemi.Columns.Remove(item);
  94. }
  95. ClientRequestEntity cre = new ClientRequestEntity();
  96. cre.NameSpace = "R03";
  97. cre.Name = "R030115S";
  98. cre.Properties["PTID"] = (this.cboPT.SelectedValue == DBNull.Value ? null : this.cboPT.SelectedValue);
  99. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  100. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  101. cre.Properties["DateBegin"] = this.txtTimeStart.Value;
  102. cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
  103. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  104. {
  105. return ReportModuleProxy.Service.DoRequest(cre);
  106. });
  107. if (resultEntity == null || resultEntity.Data == null ||
  108. resultEntity.Data.Tables.Count == 0 ||
  109. resultEntity.Data.Tables[0].Rows.Count == 0)
  110. {
  111. return;
  112. }
  113. else
  114. {
  115. for (int i = 8; i < resultEntity.Data.Tables[0].Columns.Count; i++)
  116. {
  117. DataColumn d = resultEntity.Data.Tables[0].Columns[i];
  118. DataGridViewTextBoxColumn dc = new DataGridViewTextBoxColumn();
  119. dc.Name = "D" + i;
  120. dc.DataPropertyName = d.ColumnName;
  121. dc.HeaderText = d.ColumnName;
  122. dc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
  123. dc.DefaultCellStyle.Format = "N0";
  124. dc.Tag = 1;
  125. this.dgvSemi.Columns.Add(dc);
  126. }
  127. this.dgvSemi.DataSource = resultEntity.Data.Tables[0];
  128. this.dgvSemi.ReadOnly = true;
  129. this.dgvSemi.Rows[0].Selected = true;
  130. this.dgvSemi.AutoResizeColumns();
  131. }
  132. }
  133. else if (this.tabControl1.SelectedIndex == 1)
  134. {
  135. this.dgvPT.DataSource = null;
  136. ClientRequestEntity cre = new ClientRequestEntity();
  137. cre.NameSpace = "R03";
  138. cre.Name = "R030115";
  139. cre.Properties["PTID"] = (this.cboPT.SelectedValue == DBNull.Value ? null : this.cboPT.SelectedValue);
  140. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  141. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  142. cre.Properties["DateBegin"] = this.txtTimeStart.Value;
  143. cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
  144. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  145. {
  146. return ReportModuleProxy.Service.DoRequest(cre);
  147. });
  148. if (resultEntity == null || resultEntity.Data == null ||
  149. resultEntity.Data.Tables.Count == 0 ||
  150. resultEntity.Data.Tables[0].Rows.Count == 0)
  151. {
  152. return;
  153. }
  154. else
  155. {
  156. this.dgvPT.DataSource = resultEntity.Data.Tables[0];
  157. this.dgvPT.ReadOnly = true;
  158. this.dgvPT.Rows[0].Selected = true;
  159. }
  160. }
  161. // 明细表
  162. else
  163. {
  164. this.dgvDetail.DataSource = null;
  165. ClientRequestEntity cre = new ClientRequestEntity();
  166. cre.NameSpace = "R03";
  167. cre.Name = "R030115D";
  168. cre.Properties["PTID"] = (this.cboPT.SelectedValue == DBNull.Value ? null : this.cboPT.SelectedValue);
  169. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  170. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  171. cre.Properties["DateBegin"] = this.txtTimeStart.Value;
  172. cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
  173. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  174. {
  175. return ReportModuleProxy.Service.DoRequest(cre);
  176. });
  177. if (resultEntity == null || resultEntity.Data == null ||
  178. resultEntity.Data.Tables.Count == 0 ||
  179. resultEntity.Data.Tables[0].Rows.Count == 0)
  180. {
  181. return;
  182. }
  183. else
  184. {
  185. this.dgvDetail.DataSource = resultEntity.Data.Tables[0];
  186. this.dgvDetail.ReadOnly = true;
  187. this.dgvDetail.Rows[0].Selected = true;
  188. }
  189. }
  190. }
  191. catch (Exception ex)
  192. {
  193. // 对异常进行共通处理
  194. ExceptionManager.HandleEventException(this.ToString(),
  195. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  196. }
  197. }
  198. /// <summary>
  199. /// 清空条件
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void btnClearCondition_Click(object sender, EventArgs e)
  204. {
  205. if (this.cboPT.Items.Count > 0)
  206. {
  207. this.cboPT.SelectedIndex = 0;
  208. }
  209. this.scbGoodsType.ClearValue();
  210. this.txtGoodsCode.Text = string.Empty;
  211. DateTime date = DateTime.Now;
  212. this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
  213. this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
  214. }
  215. /// <summary>
  216. /// 关闭一览窗体
  217. /// </summary>
  218. /// <param name="sender"></param>
  219. /// <param name="e"></param>
  220. private void tsbtnClose_Click(object sender, EventArgs e)
  221. {
  222. this.Close();
  223. }
  224. /// <summary>
  225. /// 窗体关闭事件
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void F_RPT_030110_FormClosed(object sender, FormClosedEventArgs e)
  230. {
  231. _instance = null;
  232. }
  233. /// <summary>
  234. /// 自动列宽
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  239. {
  240. this.dgvPT.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  241. this.dgvDetail.AutoResizeColumns();
  242. this.dgvSemi.AutoResizeColumns();
  243. }
  244. /// <summary>
  245. /// 窗体加载
  246. /// </summary>
  247. /// <param name="sender"></param>
  248. /// <param name="e"></param>
  249. private void F_RPT_030110_Load(object sender, EventArgs e)
  250. {
  251. try
  252. {
  253. // 加载权限
  254. FormPermissionManager.FormPermissionControl(this.Name, this,
  255. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  256. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  257. this.dgvPT.AutoGenerateColumns = false;
  258. // 设置日期控件默认值
  259. DateTime date = DateTime.Now;
  260. this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
  261. this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
  262. // 加载初始化数据源 工序配置
  263. ServiceResultEntity sre = ReportModuleProxy.Service.GetRPT030111IData();
  264. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  265. {
  266. sre.Data.Tables[0].Rows.InsertAt(sre.Data.Tables[0].NewRow(), 0);
  267. this.cboPT.DataSource = sre.Data.Tables[0];
  268. this.cboPT.DisplayMember = "Name";
  269. this.cboPT.ValueMember = "ptid";
  270. if (this.cboPT.Items.Count > 1)
  271. {
  272. this.cboPT.SelectedIndex = 1;
  273. }
  274. }
  275. }
  276. catch (Exception ex)
  277. {
  278. // 对异常进行共通处理
  279. ExceptionManager.HandleEventException(this.ToString(),
  280. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  281. }
  282. }
  283. #endregion
  284. #region 私有方法
  285. /// <summary>
  286. /// 根据界面查询条件获取数据集
  287. /// </summary>
  288. private DataTable GetData(ClientRequestEntity cre)
  289. {
  290. try
  291. {
  292. ServiceResultEntity resultEntity = ReportModuleProxy.Service.DoRequest(cre);
  293. if (resultEntity == null || resultEntity.Data == null || resultEntity.Data.Tables.Count == 0)
  294. {
  295. return null;
  296. }
  297. return resultEntity.Data.Tables[0];
  298. }
  299. catch (Exception ex)
  300. {
  301. throw ex;
  302. }
  303. }
  304. #endregion
  305. }
  306. }