F_PC_1202.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_1202.cs
  5. * 2.功能描述:结转
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/14 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.Client.CommonModule;
  15. using Dongke.IBOSS.PRD.Client.Controls;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. namespace Dongke.IBOSS.PRD.Client.PCModule
  19. {
  20. /// <summary>
  21. /// 结转
  22. /// </summary>
  23. public partial class F_PC_1202 : DKFormBase
  24. {
  25. #region 成员变量
  26. private static F_PC_1202 _instance = null;
  27. private string _lastYYYYMM = null;
  28. private string _nowYYYYMM = null;
  29. #endregion
  30. #region 单例模式
  31. /// <summary>
  32. /// 单例模式,防止重复创建窗体
  33. /// </summary>
  34. public static F_PC_1202 Instance
  35. {
  36. get
  37. {
  38. if (_instance == null)
  39. {
  40. _instance = new F_PC_1202();
  41. }
  42. return _instance;
  43. }
  44. }
  45. #endregion
  46. #region 构造函数
  47. /// <summary>
  48. /// 结转
  49. /// </summary>
  50. private F_PC_1202()
  51. {
  52. InitializeComponent();
  53. this.Text = "模具库存结转";
  54. }
  55. #endregion
  56. #region 事件处理
  57. /// <summary>
  58. ///
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="e"></param>
  62. private void F_PC_1202_FormClosed(object sender, FormClosedEventArgs e)
  63. {
  64. _instance = null;
  65. }
  66. /// <summary>
  67. /// 关闭
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void btnCancel_Click(object sender, EventArgs e)
  72. {
  73. this.Close();
  74. }
  75. /// <summary>
  76. /// 画面加载
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. private void F_PC_1202_Load(object sender, EventArgs e)
  81. {
  82. try
  83. {
  84. // 异步处理,获取系统参数信息
  85. ClientRequestEntity cre = new ClientRequestEntity();
  86. cre.NameSpace = "FPC1201";
  87. cre.Name = "GetFPC1202Data";
  88. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  89. DateTime curMonth = DateTime.Now;
  90. if (sre.Status == Constant.ServiceResultStatus.Success &&
  91. sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  92. {
  93. this._lastYYYYMM = sre.Data.Tables[0].Rows[0]["LastYYYYMM"].ToString();
  94. this._nowYYYYMM = sre.Data.Tables[0].Rows[0]["YYYYMM"].ToString();
  95. curMonth = Convert.ToDateTime(sre.Data.Tables[0].Rows[0]["CurMonth"]);
  96. }
  97. this.lblLastMonth.Text = string.Format(this.lblLastMonth.Text, this._lastYYYYMM);
  98. this.lblMessage.Text = string.Format(this.lblMessage.Text, this._lastYYYYMM, this._nowYYYYMM);
  99. this.dtpMonth.Value = curMonth.AddMonths(-1);
  100. this.dtpMonth_ValueChanged(null, null);
  101. }
  102. catch (Exception ex)
  103. {
  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 btnSave_Click(object sender, EventArgs e)
  115. {
  116. try
  117. {
  118. string yyyymm = this.dtpMonth.Value.Value.ToString("yyyyMM");
  119. if (yyyymm.CompareTo(this._lastYYYYMM) <= 0 || yyyymm.CompareTo(this._nowYYYYMM) >= 0)
  120. {
  121. MessageBox.Show(this.lblMessage.Text, this.Text,
  122. MessageBoxButtons.OK,
  123. MessageBoxIcon.Warning);
  124. return;
  125. }
  126. // 异步处理,获取系统参数信息
  127. ClientRequestEntity cre = new ClientRequestEntity();
  128. cre.NameSpace = "FPC1201";
  129. cre.Name = "SetFPC1202Data";
  130. cre.Properties["CarryoverMonth"] = this.dtpMonth.Value.Value;
  131. cre.Properties["Remarks"] = this.txtRemarks.Text;
  132. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(() =>
  133. {
  134. return PCModuleProxyNew.Service.HandleRequest(cre);
  135. }
  136. );
  137. if (sre.Status == Constant.ServiceResultStatus.Success)
  138. {
  139. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "结转"),
  140. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  141. // 关闭窗体
  142. this.Close();
  143. }
  144. else
  145. {
  146. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, this.Text, "结转"),
  147. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  148. }
  149. }
  150. catch (Exception ex)
  151. {
  152. // 对异常进行共通处理
  153. ExceptionManager.HandleEventException(this.ToString(),
  154. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  155. }
  156. }
  157. private void dtpMonth_ValueChanged(object sender, EventArgs e)
  158. {
  159. this.txtDateBegin.Text = this.dtpMonth.Value.Value.ToString("yyyy-MM-dd");
  160. this.txtDateEnd.Text = this.dtpMonth.Value.Value.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
  161. }
  162. #endregion
  163. }
  164. }