using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using BO.Utils; using BO.Utils.BillRpc; using BWP.WinFormControl; using Distribution.LocalBo; namespace Distribution { public partial class DistributionForm : Form,IAfterLogin { public string RoleName { get { return "配货员"; } } public Form Generate() { return this; } private bool mIsCustomerSynced, mIsDeliverGoodsLineSynced; private bool mIsFirstSearch = true; private BackgroundWorker mBackgroundWorkerSyncBaseInfo; private BindingList mSaleOutStoreList; private BindingList mSaleOutStoreAllList; public DistributionForm() { InitializeComponent(); dataGridViewSaleOutStore.AutoGenerateColumns = false; dataGridViewDingHuo.AutoGenerateColumns = false; dataGridViewFaHuo.AutoGenerateColumns = false; cbxSelectCustomer.Init(x => CustomerRpc.SyncListForDropDown(x,!mIsCustomerSynced)); cbxSelectXianLu.Init(x => DeliverGoodsLineRpc.SyncListForDropDown(x,!mIsDeliverGoodsLineSynced)); mBackgroundWorkerSyncBaseInfo =new BackgroundWorker(); mBackgroundWorkerSyncBaseInfo.DoWork += backgroundWorkerSyncBaseInfo_DoWork; mBackgroundWorkerSyncBaseInfo.RunWorkerCompleted += backgroundWorkerSyncBaseInfo_RunWorkerCompleted; mBackgroundWorkerSyncBaseInfo.RunWorkerAsync(); } private void backgroundWorkerSyncBaseInfo_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { mIsCustomerSynced = true; mIsDeliverGoodsLineSynced = true; } private void backgroundWorkerSyncBaseInfo_DoWork(object sender, DoWorkEventArgs e) { CustomerRpc.SyncList(); DeliverGoodsLineRpc.SyncList(); } private void DistributionForm_Load(object sender, EventArgs e) { } private void btnSearch_Click(object sender, EventArgs e) { mSaleOutStoreAllList = SaleOutStoreRpc.SyncList(dateInput.Date.Value, cbxSelectCustomer.Text, cbxSelectXianLu.Text, "", mIsFirstSearch); SetSaleOutStoreList(); dataGridViewSaleOutStore.DataSource = mSaleOutStoreList; mIsFirstSearch = false; } void SetSaleOutStoreList() { mSaleOutStoreList=new BindingList(); foreach (var grouping in mSaleOutStoreAllList.GroupBy(x=>x.SaleOutStore_ID)) { var fd = grouping.FirstOrDefault(); if (fd != null) { mSaleOutStoreList.Add(fd); } } } } }