using DB.Service; using HZH_Controls.Controls; 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; namespace RfidWeb.Frm { public partial class FrmBarCodeGridView : UserControl { private ReadBufLogService readBufLogService = new ReadBufLogService(); public FrmBarCodeGridView() { InitializeComponent(); this.dataGridView1.Columns["CreateTime"].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss"; var keyValue= new List>(); keyValue.Add(new KeyValuePair("A", "收料1")); keyValue.Add(new KeyValuePair("B", "收料2")); keyValue.Add(new KeyValuePair("C", "废料")); ucHorizontalList1.DataSource = keyValue; var dt = DateTime.Now; var a = Convert.ToDateTime(dt.ToString("yyyy-MM-dd 00:00:00")); var b = Convert.ToDateTime(dt.ToString("yyyy-MM-dd 23:59:00")); this.ucDatePickerExt21.CurrentTime = a; this.ucDatePickerExt22.CurrentTime = b; this.dataGridView1.AutoGenerateColumns = false; ucPagerControl21.PageModel = PageModel.PageCount; ucPagerControl21.PageIndex = 1; ucPagerControl21.PageSize = 20; this.ucPagerControl21.ShowSourceChanged += new HZH_Controls.Controls.PageControlEventHandler(this.ucPagerControl21_ShowSourceChanged); this.ucHorizontalList1.SelectedItemEvent += new System.EventHandler(this.ucHorizontalList1_SelectedItemEvent); ucPagerControl21_ShowSourceChanged(new object()); } private void Replace() { ucPagerControl21.PageIndex = 1; ucPagerControl21_ShowSourceChanged(new object()); } private void ucPagerControl21_ShowSourceChanged(object currentSource) { this.dataGridView1.AutoGenerateColumns = false; var selectedItemDataSource = ucHorizontalList1.SelectedItem.DataSource; string key = selectedItemDataSource.Key; var beginTime = ucDatePickerExt21.CurrentTime; var endTime = ucDatePickerExt22.CurrentTime; int index = ucPagerControl21.PageIndex; var page = readBufLogService.GetPagedList(ucPagerControl21.PageIndex, ucPagerControl21.PageSize, key,beginTime,endTime); ucPagerControl21.PageCount = page.TotalPages; this.dataGridView1.DataSource = page.Items; } private void ucBtnSelect_BtnClick(object sender, EventArgs e) { Replace(); } private void ucHorizontalList1_SelectedItemEvent(object sender, EventArgs e) { Replace(); } } }