frmBalanceStatisticsSearch.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using ComponentFactory.Krypton.Toolkit;
  2. using NXWMS.Client.Code.Extends;
  3. using NXWMS.Client.Model.AppModels.Condition.Balance;
  4. using NXWMS.Client.Model.AppModels.Condition.Base;
  5. using NXWMS.Client.Model.AppModels.Result;
  6. using NXWMS.Client.Model.AppModels.Result.Balance;
  7. using NXWMS.Client.Model.AppModels.Result.Base;
  8. using NXWMS.Client.Model.CoreModels;
  9. using NXWMS.Commons;
  10. using NXWMS.Services;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. namespace NXWMS.Forms.Balance
  20. {
  21. public partial class frmBalanceStatisticsSearch : KryptonForm
  22. {
  23. /// <summary>
  24. /// 窗体类名
  25. /// </summary>
  26. private string _CrrentClassName;
  27. /// <summary>
  28. /// 客户端字段排序列表
  29. /// </summary>
  30. private List<ClientFieldOrderResult> _clientFieldOrderList;
  31. /// <summary>
  32. /// 库区
  33. /// </summary>
  34. private List<RegionResult> regionList;
  35. /// <summary>
  36. /// 物料类型列表
  37. /// </summary>
  38. private List<MaterielTypeResult> materielTypeList;
  39. /// <summary>
  40. /// 单位列表
  41. /// </summary>
  42. private List<UnitResult> unitList;
  43. public frmBalanceStatisticsSearch()
  44. {
  45. InitializeComponent();
  46. _CrrentClassName = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
  47. InitData();
  48. InitControl();
  49. _pageIndex = 1;
  50. _pageSize = 20;
  51. }
  52. /// <summary>
  53. /// 控件初始化
  54. /// </summary>
  55. private void InitControl()
  56. {
  57. CheckForIllegalCrossThreadCalls = false;
  58. dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
  59. var fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
  60. cmbSearchRegionCode.DataSource = fieldList.GetFieldValueCodeList(regionList, "REGION_CODE", "REGION_NAME");
  61. cmbSearchRegionCode.DisplayMember = "Name";
  62. cmbSearchRegionCode.ValueMember = "Code";
  63. cmbSearchRegionCode.SelectedIndex = -1;
  64. fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
  65. cmbSearchMaterielType.DataSource = fieldList.GetFieldValueCodeList(materielTypeList, "MATERIEL_TYPE_CODE", "MATERIEL_TYPE_NAME");
  66. cmbSearchMaterielType.DisplayMember = "Name";
  67. cmbSearchMaterielType.ValueMember = "Code";
  68. cmbSearchMaterielType.SelectedIndex = -1;
  69. fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
  70. cmbSearchUnit.DataSource = fieldList.GetFieldValueCodeList(unitList, "UNIT_CODE", "UNIT_NAME"); ;
  71. cmbSearchUnit.DisplayMember = "Name";
  72. cmbSearchUnit.ValueMember = "Code";
  73. cmbSearchUnit.SelectedIndex = -1;
  74. _pageIndex = 1;
  75. _pageSize = 20;
  76. }
  77. /// <summary>
  78. /// 数据初始化
  79. /// </summary>
  80. private void InitData()
  81. {
  82. var regionResult = BaseServices.regionService.GetList(new RegionSearchCondition { IsUsed = true, ItemSQL = "REGION_CODE,REGION_NAME" });
  83. if (regionResult.Status == OperateStatus.Success)
  84. {
  85. regionList = regionResult.Data.RowData.ToList();
  86. }
  87. var materielTypeResult = BaseServices.materielTypeService.GetList(new MaterielTypeSearchCondition { IsUsed = true, ItemSQL = "MATERIEL_TYPE_CODE,MATERIEL_TYPE_NAME" });
  88. if (materielTypeResult.Status == OperateStatus.Success)
  89. {
  90. materielTypeList = materielTypeResult.Data.RowData.ToList();
  91. }
  92. var unitResult = BaseServices.unitService.GetList(new UnitSearchCondition { IsUsed = true, ItemSQL = "UNIT_CODE,UNIT_NAME" });
  93. if (unitResult.Status == OperateStatus.Success)
  94. {
  95. unitList = unitResult.Data.RowData.ToList();
  96. }
  97. _clientFieldOrderList = new List<ClientFieldOrderResult>();
  98. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "WarehouseName", FieldDesc = "仓库" });
  99. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "RegionName", FieldDesc = "库区" });
  100. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielTypeCode", FieldDesc = "物料类型编码" });
  101. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielTypeName", FieldDesc = "物料类型名称" });
  102. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielCode", FieldDesc = "物料编码" });
  103. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielName", FieldDesc = "物料名称" });
  104. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UnitName", FieldDesc = "单位" });
  105. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "BatchNo", FieldDesc = "批次号" });
  106. _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "QTY", FieldDesc = "总数量" });
  107. }
  108. private void btnSearch_Click(object sender, EventArgs e)
  109. {
  110. _pageIndex = 1;
  111. var loadfrm = new frmLoading();
  112. loadfrm.Show();
  113. //pageTool.Initialize(LoadSearch, 0, _pageSize);
  114. var message = loadfrm.EventCalExec(LoadSearch, this.pageTool.PageIndex, this.pageTool.PageSize);
  115. pageTool.DataCount = _totalCount;
  116. if (!string.IsNullOrWhiteSpace(message))
  117. {
  118. KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  119. }
  120. }
  121. private int _pageSize;
  122. private int _pageIndex;
  123. private int _totalCount;
  124. private string LoadSearch(int pageIndex, int pageSize)
  125. {
  126. var result = BalanceServices.balanceSearchService.GetStatisticsList(new BalanceStatisticsSearchCondition
  127. {
  128. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  129. MaterielType = cmbSearchMaterielType.GetObjectToString(),
  130. BatchNo = txtSearchBatchNo.Text,
  131. MaterielInfo = txtSearchMaterielInfo.Text,
  132. RegionInfo = cmbSearchRegionCode.GetObjectToString(),
  133. UnitCode = cmbSearchUnit.GetObjectToString(),
  134. WarehouseInfo = txtSearchWarehouseInfo.Text,
  135. PageIndex = pageIndex,
  136. PageSize = pageSize
  137. });
  138. if (result.Status == OperateStatus.Success)
  139. {
  140. _totalCount = result.Data.TotalCount;
  141. _pageIndex = pageIndex;
  142. _pageSize = pageSize;
  143. if (result.Data.RowData.Any())
  144. {
  145. dataGridView.Columns.Clear();
  146. dataGridView.DataSource = result.Data.RowData.ToList();
  147. dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList));
  148. }
  149. else
  150. {
  151. if (dataGridView.DataSource != null)
  152. {
  153. dataGridView.DataSource = new List<BalanceStatisticsSearchResult>();
  154. }
  155. dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
  156. }
  157. return string.Empty;
  158. }
  159. else
  160. {
  161. return result.Message;
  162. }
  163. }
  164. private void btnSearchExport_Click(object sender, EventArgs e)
  165. {
  166. this.dataGridView.DataGridViewExport($"{AppConfig.CurrentMenu.FirstOrDefault().MenuName}列表" + DateTime.Now.ToString("yyyyMMddHH"));
  167. }
  168. }
  169. }