123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- using ComponentFactory.Krypton.Toolkit;
- using NXWMS.Client.Code.Extends;
- using NXWMS.Client.Model.AppModels.Condition.Balance;
- using NXWMS.Client.Model.AppModels.Condition.Base;
- using NXWMS.Client.Model.AppModels.Result;
- using NXWMS.Client.Model.AppModels.Result.Balance;
- using NXWMS.Client.Model.AppModels.Result.Base;
- using NXWMS.Client.Model.CoreModels;
- using NXWMS.Commons;
- using NXWMS.Services;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace NXWMS.Forms.Balance
- {
- public partial class frmBalanceStatisticsSearch : KryptonForm
- {
- /// <summary>
- /// 窗体类名
- /// </summary>
- private string _CrrentClassName;
- /// <summary>
- /// 客户端字段排序列表
- /// </summary>
- private List<ClientFieldOrderResult> _clientFieldOrderList;
- /// <summary>
- /// 库区
- /// </summary>
- private List<RegionResult> regionList;
- /// <summary>
- /// 物料类型列表
- /// </summary>
- private List<MaterielTypeResult> materielTypeList;
- /// <summary>
- /// 单位列表
- /// </summary>
- private List<UnitResult> unitList;
- public frmBalanceStatisticsSearch()
- {
- InitializeComponent();
- _CrrentClassName = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
- InitData();
- InitControl();
- _pageIndex = 1;
- _pageSize = 20;
- }
- /// <summary>
- /// 控件初始化
- /// </summary>
- private void InitControl()
- {
- CheckForIllegalCrossThreadCalls = false;
- dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
- var fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
- cmbSearchRegionCode.DataSource = fieldList.GetFieldValueCodeList(regionList, "REGION_CODE", "REGION_NAME");
- cmbSearchRegionCode.DisplayMember = "Name";
- cmbSearchRegionCode.ValueMember = "Code";
- cmbSearchRegionCode.SelectedIndex = -1;
- fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
- cmbSearchMaterielType.DataSource = fieldList.GetFieldValueCodeList(materielTypeList, "MATERIEL_TYPE_CODE", "MATERIEL_TYPE_NAME");
- cmbSearchMaterielType.DisplayMember = "Name";
- cmbSearchMaterielType.ValueMember = "Code";
- cmbSearchMaterielType.SelectedIndex = -1;
- fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
- cmbSearchUnit.DataSource = fieldList.GetFieldValueCodeList(unitList, "UNIT_CODE", "UNIT_NAME"); ;
- cmbSearchUnit.DisplayMember = "Name";
- cmbSearchUnit.ValueMember = "Code";
- cmbSearchUnit.SelectedIndex = -1;
- _pageIndex = 1;
- _pageSize = 20;
- }
- /// <summary>
- /// 数据初始化
- /// </summary>
- private void InitData()
- {
- var regionResult = BaseServices.regionService.GetList(new RegionSearchCondition { IsUsed = true, ItemSQL = "REGION_CODE,REGION_NAME" });
- if (regionResult.Status == OperateStatus.Success)
- {
- regionList = regionResult.Data.RowData.ToList();
- }
- var materielTypeResult = BaseServices.materielTypeService.GetList(new MaterielTypeSearchCondition { IsUsed = true, ItemSQL = "MATERIEL_TYPE_CODE,MATERIEL_TYPE_NAME" });
- if (materielTypeResult.Status == OperateStatus.Success)
- {
- materielTypeList = materielTypeResult.Data.RowData.ToList();
- }
- var unitResult = BaseServices.unitService.GetList(new UnitSearchCondition { IsUsed = true, ItemSQL = "UNIT_CODE,UNIT_NAME" });
- if (unitResult.Status == OperateStatus.Success)
- {
- unitList = unitResult.Data.RowData.ToList();
- }
- _clientFieldOrderList = new List<ClientFieldOrderResult>();
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "WarehouseName", FieldDesc = "仓库" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "RegionName", FieldDesc = "库区" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielTypeCode", FieldDesc = "物料类型编码" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielTypeName", FieldDesc = "物料类型名称" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielCode", FieldDesc = "物料编码" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielName", FieldDesc = "物料名称" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UnitName", FieldDesc = "单位" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "BatchNo", FieldDesc = "批次号" });
- _clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "QTY", FieldDesc = "总数量" });
- }
- private void btnSearch_Click(object sender, EventArgs e)
- {
- _pageIndex = 1;
- var loadfrm = new frmLoading();
- loadfrm.Show();
- //pageTool.Initialize(LoadSearch, 0, _pageSize);
- var message = loadfrm.EventCalExec(LoadSearch, this.pageTool.PageIndex, this.pageTool.PageSize);
- pageTool.DataCount = _totalCount;
- if (!string.IsNullOrWhiteSpace(message))
- {
- KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private int _pageSize;
- private int _pageIndex;
- private int _totalCount;
- private string LoadSearch(int pageIndex, int pageSize)
- {
- var result = BalanceServices.balanceSearchService.GetStatisticsList(new BalanceStatisticsSearchCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- MaterielType = cmbSearchMaterielType.GetObjectToString(),
- BatchNo = txtSearchBatchNo.Text,
- MaterielInfo = txtSearchMaterielInfo.Text,
- RegionInfo = cmbSearchRegionCode.GetObjectToString(),
- UnitCode = cmbSearchUnit.GetObjectToString(),
- WarehouseInfo = txtSearchWarehouseInfo.Text,
- PageIndex = pageIndex,
- PageSize = pageSize
- });
- if (result.Status == OperateStatus.Success)
- {
- _totalCount = result.Data.TotalCount;
- _pageIndex = pageIndex;
- _pageSize = pageSize;
- if (result.Data.RowData.Any())
- {
- dataGridView.Columns.Clear();
- dataGridView.DataSource = result.Data.RowData.ToList();
- dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList));
- }
- else
- {
- if (dataGridView.DataSource != null)
- {
- dataGridView.DataSource = new List<BalanceStatisticsSearchResult>();
- }
- dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
- }
- return string.Empty;
- }
- else
- {
- return result.Message;
- }
- }
- private void btnSearchExport_Click(object sender, EventArgs e)
- {
- this.dataGridView.DataGridViewExport($"{AppConfig.CurrentMenu.FirstOrDefault().MenuName}列表" + DateTime.Now.ToString("yyyyMMddHH"));
- }
- }
- }
|