F_PC_1201.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. 
  2. /*******************************************************************************
  3. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  4. * 类的信息:
  5. * 1.程序名称:F_PC_1201.cs
  6. * 2.功能描述:模具库存结转一览
  7. * 编辑履历:
  8. * 作者 日期 版本 修改内容
  9. * 陈晓野 2017/12/07 1.00 新建
  10. *******************************************************************************/
  11. using System;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  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.Proxys;
  20. namespace Dongke.IBOSS.PRD.Client.PCModule
  21. {
  22. /// <summary>
  23. /// 模具档案
  24. /// </summary>
  25. public partial class F_PC_1201 : DKDockPanelBase
  26. {
  27. #region 成员变量
  28. private static F_PC_1201 _instance = null;
  29. private bool _isSearch = false;
  30. #endregion
  31. #region 单例模式
  32. /// <summary>
  33. /// 单例模式,防止重复创建窗体
  34. /// </summary>
  35. public static F_PC_1201 Instance
  36. {
  37. get
  38. {
  39. if (_instance == null)
  40. {
  41. _instance = new F_PC_1201();
  42. }
  43. return _instance;
  44. }
  45. }
  46. #endregion
  47. #region 构造函数
  48. /// <summary>
  49. ///
  50. /// </summary>
  51. public F_PC_1201()
  52. {
  53. InitializeComponent();
  54. this.Text = "模具库存结转";
  55. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  56. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  57. this.dgvCarryOver.AutoGenerateColumns = false;
  58. this.dgvDetail.AutoGenerateColumns = false;
  59. }
  60. #endregion
  61. #region 控件事件
  62. /// <summary>
  63. /// 关闭
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_PC_1001_FormClosed(object sender, FormClosedEventArgs e)
  68. {
  69. _instance = null;
  70. }
  71. /// <summary>
  72. /// 画面加载
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_PC_1001_Load(object sender, System.EventArgs e)
  77. {
  78. try
  79. {
  80. FormPermissionManager.FormPermissionControl(this.Name, this,
  81. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  82. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  83. this.dtpMonthEnd.Value = DateTime.Now.AddMonths(-1);
  84. this.dtpMonthBegin.Value = DateTime.Now.AddMonths(-7);
  85. }
  86. catch (Exception ex)
  87. {
  88. // 对异常进行共通处理
  89. ExceptionManager.HandleEventException(this.ToString(),
  90. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  91. }
  92. }
  93. /// <summary>
  94. /// 自适应列宽
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  99. {
  100. this.dgvCarryOver.AutoResizeColumns();
  101. this.dgvDetail.AutoResizeColumns();
  102. }
  103. /// <summary>
  104. /// 清除查询条件
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  109. {
  110. this.dtpMonthEnd.Value = DateTime.Now.AddMonths(-1);
  111. this.dtpMonthBegin.Value = DateTime.Now.AddMonths(-7);
  112. this.txtRemarks.Clear();
  113. }
  114. /// <summary>
  115. /// 查询
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void tsbtnSearch_Click(object sender, EventArgs e)
  120. {
  121. try
  122. {
  123. this.QueryDataFromOther();
  124. }
  125. catch (Exception ex)
  126. {
  127. // 对异常进行共通处理
  128. ExceptionManager.HandleEventException(this.ToString(),
  129. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  130. }
  131. }
  132. /// <summary>
  133. ///
  134. /// </summary>
  135. /// <param name="sender"></param>
  136. /// <param name="e"></param>
  137. private void dgvCarryOver_SelectionChanged(object sender, EventArgs e)
  138. {
  139. if (_isSearch || this.dgvCarryOver.CurrentRow == null || this.dgvCarryOver.CurrentRow.Index < 0)
  140. {
  141. return;
  142. }
  143. try
  144. {
  145. ClientRequestEntity cre = new ClientRequestEntity();
  146. cre.NameSpace = "FPC1201";
  147. cre.Name = "GetFPC1201QueryDetailData";
  148. cre.Properties["YYYYMM"] = this.dgvCarryOver.CurrentRow.Cells["YYYYMM"].Value.ToString();
  149. this.dgvDetail.DataSource = null;
  150. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  151. {
  152. return PCModuleProxyNew.Service.HandleRequest(cre);
  153. }
  154. );
  155. if (sre.Status == Constant.ServiceResultStatus.Success)
  156. {
  157. // 查询成功
  158. this.dgvDetail.DataSource = sre.Data.Tables[0];
  159. }
  160. }
  161. catch (Exception ex)
  162. {
  163. // 对异常进行共通处理
  164. ExceptionManager.HandleEventException(this.ToString(),
  165. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  166. }
  167. }
  168. /// <summary>
  169. /// 设置自动结转
  170. /// </summary>
  171. /// <param name="sender"></param>
  172. /// <param name="e"></param>
  173. private void tsbtnAutoCarryover_Click(object sender, EventArgs e)
  174. {
  175. try
  176. {
  177. F_PC_1204 f1204 = new F_PC_1204();
  178. f1204.ShowDialog();
  179. }
  180. catch (Exception ex)
  181. {
  182. // 对异常进行共通处理
  183. ExceptionManager.HandleEventException(this.ToString(),
  184. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  185. }
  186. }
  187. /// <summary>
  188. /// 结转
  189. /// </summary>
  190. /// <param name="sender"></param>
  191. /// <param name="e"></param>
  192. private void tsbtnCarryover_Click(object sender, EventArgs e)
  193. {
  194. try
  195. {
  196. F_PC_1202 f1202 = F_PC_1202.Instance;
  197. f1202.Show();
  198. f1202.ActivateForm();
  199. f1202.BringToFront();
  200. }
  201. catch (Exception ex)
  202. {
  203. // 对异常进行共通处理
  204. ExceptionManager.HandleEventException(this.ToString(),
  205. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  206. }
  207. }
  208. /// <summary>
  209. /// 反结
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. private void tsbtnUndoCarryover_Click(object sender, EventArgs e)
  214. {
  215. if (this.dgvCarryOver.CurrentRow == null || this.dgvCarryOver.CurrentRow.Index < 0)
  216. {
  217. return;
  218. }
  219. try
  220. {
  221. string yyyymm = this.dgvCarryOver.CurrentRow.Cells["YYYYMM"].Value.ToString();
  222. DialogResult dialogResult =
  223. MessageBox.Show(string.Format("确定要对【{0}】及以后的库存结转进行反结转?", yyyymm),
  224. "模具库存反结转",
  225. MessageBoxButtons.OKCancel,
  226. MessageBoxIcon.Question,
  227. MessageBoxDefaultButton.Button2);
  228. if (dialogResult != System.Windows.Forms.DialogResult.OK)
  229. {
  230. return;
  231. }
  232. dialogResult =
  233. MessageBox.Show("反结转将会删除已结转数据,是否继续?",
  234. "模具库存反结转",
  235. MessageBoxButtons.YesNo,
  236. MessageBoxIcon.Warning,
  237. MessageBoxDefaultButton.Button2);
  238. if (dialogResult != System.Windows.Forms.DialogResult.Yes)
  239. {
  240. return;
  241. }
  242. // 异步处理,获取系统参数信息
  243. ClientRequestEntity cre = new ClientRequestEntity();
  244. cre.NameSpace = "FPC1201";
  245. cre.Name = "SetFPC1203Data";
  246. cre.Properties["YYYYMM"] = yyyymm;
  247. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(() =>
  248. {
  249. return PCModuleProxyNew.Service.HandleRequest(cre);
  250. }
  251. );
  252. if (sre.Status == Constant.ServiceResultStatus.Success)
  253. {
  254. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "【" + yyyymm + "】及以后", "库存反结转"),
  255. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  256. }
  257. else
  258. {
  259. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "【" + yyyymm + "】及以后", "库存反结转"),
  260. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  261. }
  262. this.tsbtnSearch_Click(null, null);
  263. }
  264. catch (Exception ex)
  265. {
  266. // 对异常进行共通处理
  267. ExceptionManager.HandleEventException(this.ToString(),
  268. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  269. }
  270. }
  271. /// <summary>
  272. /// 关闭画面
  273. /// </summary>
  274. /// <param name="sender"></param>
  275. /// <param name="e"></param>
  276. private void tsbtnClose_Click(object sender, EventArgs e)
  277. {
  278. this.Close();
  279. }
  280. #endregion
  281. #region 私有方法
  282. /// <summary>
  283. /// 查询数据
  284. /// </summary>
  285. /// <returns>验证通过true,其他false</returns>
  286. private void QueryDataFromOther()
  287. {
  288. try
  289. {
  290. _isSearch = true;
  291. ClientRequestEntity cre = new ClientRequestEntity();
  292. cre.NameSpace = "FPC1201";
  293. cre.Name = "GetFPC1201QueryData";
  294. cre.Properties["DateBegin"] = this.dtpMonthBegin.Value.Value.ToString("yyyyMM");
  295. cre.Properties["DateEnd"] = this.dtpMonthEnd.Value.Value.ToString("yyyyMM");
  296. this.dgvCarryOver.DataSource = null;
  297. this.dgvDetail.DataSource = null;
  298. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  299. {
  300. return PCModuleProxyNew.Service.HandleRequest(cre);
  301. }
  302. );
  303. if (sre.Status == Constant.ServiceResultStatus.Success)
  304. {
  305. // 查询成功
  306. this.dgvCarryOver.DataSource = sre.Data.Tables[0];
  307. this.dgvDetail.DataSource = sre.Data.Tables[1];
  308. }
  309. }
  310. catch (Exception ex)
  311. {
  312. throw ex;
  313. }
  314. finally
  315. {
  316. _isSearch = false;
  317. }
  318. }
  319. #endregion
  320. }
  321. }