F_RPT_040116.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_040116.cs
  5. * 2.功能描述:月度成品入库预算表-恒洁三水(定制)
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张庭莲 2022/11/25 1.00 新建
  9. *******************************************************************************/
  10. using Dongke.IBOSS.PRD.Basics.BaseResources;
  11. using Dongke.IBOSS.PRD.Client.CommonModule;
  12. using Dongke.IBOSS.PRD.Client.Controls;
  13. using Dongke.IBOSS.PRD.Client.DataModels;
  14. using Dongke.IBOSS.PRD.WCF.DataModels;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using System;
  17. using System.Windows.Forms;
  18. namespace Dongke.IBOSS.PRD.Client.ReportModule.R04.M01
  19. {
  20. public partial class F_RPT_040116 : DKDockPanelBase
  21. {
  22. #region 成员变量
  23. // 窗体的单例模式
  24. private static F_RPT_040116 _instance;
  25. private ClientRequestEntity _cre = null;
  26. #endregion
  27. #region 构造函数
  28. public F_RPT_040116()
  29. {
  30. InitializeComponent();
  31. this.Text = "月度成品入库预算表";
  32. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  33. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  34. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  35. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  36. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  37. }
  38. #endregion
  39. #region 单例模式
  40. /// <summary>
  41. /// 单例模式,防止重复创建窗体
  42. /// </summary>
  43. public static F_RPT_040116 Instance
  44. {
  45. get
  46. {
  47. if (_instance == null || _instance.IsDisposed)
  48. {
  49. _instance = new F_RPT_040116();
  50. }
  51. return _instance;
  52. }
  53. }
  54. #endregion
  55. #region 事件处理
  56. /// <summary>
  57. /// 页面加载事件
  58. /// </summary>
  59. private void F_RPT_040116_Load(object sender, EventArgs e)
  60. {
  61. try
  62. {
  63. // 加载权限
  64. FormPermissionManager.FormPermissionControl(this.Name, this,
  65. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  66. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  67. // 设置表格不自动创建列
  68. this.dgvGroutingAdobeTotal.AutoGenerateColumns = false;
  69. }
  70. catch (Exception ex)
  71. {
  72. // 对异常进行共通处理
  73. ExceptionManager.HandleEventException(this.ToString(),
  74. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  75. }
  76. }
  77. /// <summary>
  78. /// 清空事件
  79. /// </summary>
  80. private void btnClearCondition_Click(object sender, EventArgs e)
  81. {
  82. cleared();
  83. }
  84. /// <summary>
  85. /// 查询事件
  86. /// </summary>
  87. private void btnSearch_Click(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. this.dgvGroutingAdobeTotal.DataSource = null;
  92. _cre = new ClientRequestEntity();
  93. _cre.NameSpace = "R04";
  94. _cre.Name = "R040116";
  95. this.SetDate();
  96. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  97. {
  98. return ReportModuleProxy.Service.DoRequest(_cre);
  99. });
  100. if (resultEntity != null && resultEntity.Data != null &&
  101. resultEntity.Data.Tables.Count > 0)
  102. {
  103. this.dgvGroutingAdobeTotal.DataSource = resultEntity.Data.Tables[0];
  104. }
  105. }
  106. catch (Exception ex)
  107. {
  108. // 对异常进行共通处理
  109. ExceptionManager.HandleEventException(this.ToString(),
  110. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  111. }
  112. }
  113. /// <summary>
  114. /// 关闭事件
  115. /// </summary>
  116. /// <param name="sender"></param>
  117. /// <param name="e"></param>
  118. private void tsbtnClose_Click(object sender, EventArgs e)
  119. {
  120. this.Close();
  121. }
  122. /// <summary>
  123. /// 自动适应列宽
  124. /// </summary>
  125. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  126. {
  127. this.dgvGroutingAdobeTotal.AutoResizeColumns();
  128. }
  129. /// <summary>
  130. /// 窗体关闭事件
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. private void F_RPT_040116_FormClosed(object sender, FormClosedEventArgs e)
  135. {
  136. _instance = null;
  137. }
  138. #endregion
  139. #region 私有方法
  140. /// <summary>
  141. /// 获取日期以及条件查询
  142. /// </summary>
  143. private void SetDate()
  144. {
  145. //获得当前的年月
  146. string GDateStart = DateTime.Now.ToString("yyyy-MM");
  147. string MonthDays = this.dtpGDateStart.Text;
  148. _cre.Properties["Month"] = MonthDays;
  149. //判断当前的年月和数据的年月是否相等
  150. if (GDateStart.Equals(this.dtpGDateStart.Value.ToString("yyyy-MM")))
  151. {
  152. //开始时间 timebegin
  153. string timebegin;
  154. //结束时间 timeend
  155. string timeend = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  156. object timeendd = DateTime.Now.ToString("dd");
  157. if (Convert.ToInt32(timeendd) < 15)
  158. {
  159. int days = 15 - Convert.ToInt32(timeendd);
  160. //上个月最后一天 MonthDay
  161. DateTime MonthDay = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddDays(-1);
  162. int MonthDayint = Convert.ToInt32(MonthDay.ToString("dd"));
  163. int timebegind = MonthDayint - days;
  164. //上个月的开始日期
  165. timebegin = MonthDay.ToString("yyyy-MM") + "-" + timebegind + " " + "00:00:00";
  166. }
  167. else if (Convert.ToInt32(timeendd) == 15)
  168. {
  169. timebegin = DateTime.Now.ToString("yyyy-MM") + "-01" + " " + "00:00:00";
  170. }
  171. else
  172. {
  173. int timebegindd = (Convert.ToInt32(timeendd) - 15);
  174. if (timebegindd < 10)
  175. {
  176. timebegindd.ToString().PadLeft(2, '0');
  177. timebegin = DateTime.Now.ToString("yyyy-MM") + "-0" + timebegindd.ToString() + " " + "00:00:00";
  178. }
  179. else
  180. {
  181. timebegin = DateTime.Now.ToString("yyyy-MM") + "-" + timebegindd.ToString() + " " + "00:00:00";
  182. }
  183. }
  184. string timebeginq = DateTime.Now.ToString("yyyy-MM") + "-01" + " " + "00:00:00";
  185. _cre.Properties["TimeBegin"] = timebegin;
  186. _cre.Properties["TimeBeginTwo"] = timebeginq;
  187. _cre.Properties["TimeEnd"] = timeend;
  188. }
  189. else
  190. {
  191. string timeendy = this.dtpGDateStart.Value.ToString("yyyy");
  192. string timeendm = this.dtpGDateStart.Value.ToString("MM");
  193. object timeendd = System.DateTime.DaysInMonth(Convert.ToInt32(timeendy), Convert.ToInt32(timeendm));
  194. //结束时间 timeend
  195. string timeend = timeendy + "-" + timeendm + "-" + timeendd.ToString() + " " + "23:59:59";
  196. int timebegindd = Convert.ToInt32(timeendd) - 15;
  197. //开始时间 timebegin
  198. string timebegin = timeendy + "-" + timeendm + "-" + timebegindd.ToString() + " " + "00:00:00";
  199. string timebeginq = this.dtpGDateStart.Value.ToString("yyyy-MM") + "-01" + " " + "00:00:00";
  200. _cre.Properties["TimeBeginTwo"] = timebeginq;
  201. _cre.Properties["TimeBegin"] = timebegin;
  202. _cre.Properties["TimeEnd"] = timeend;
  203. }
  204. _cre.Properties["GroutingLineCode"] = this.txtGroutingLineCode.Text;
  205. _cre.Properties["GroutingUserCode"] = this.txtGroutingUserCode.Text;
  206. _cre.Properties["GoodCode"] = this.txtGoodCode.Text;
  207. _cre.Properties["GoodsType"] = this.scbGoodsType.SearchedValue + "";
  208. if (this.c_CheckBox1.Checked)
  209. {
  210. _cre.Properties["Subtotal"] = 1;
  211. }
  212. }
  213. /// <summary>
  214. /// 清空文本框
  215. /// </summary>
  216. private void cleared()
  217. {
  218. this.txtGroutingLineCode.Text = string.Empty;
  219. this.txtGroutingUserCode.Text = string.Empty;
  220. this.txtGoodCode.Text = string.Empty;
  221. this.scbGoodsType.ClearValue();
  222. string GDateStart = DateTime.Now.ToString("yyyy-MM");
  223. this.dtpGDateStart.Text = GDateStart;
  224. this.c_CheckBox1.Checked = false;
  225. }
  226. #endregion
  227. }
  228. }