/// <summary> /// 绑定CostumeStore数据源 /// </summary> /// <param name="listPage"></param> private void BindingCostumeStoreDataSource(List <PfCustomerInvoicing> listPage) { SetDisplay(); if (!String.IsNullOrEmpty(this.skinTextBox_costumeID.Text) && skinComboBox_PfCustomer.SelectedValue == null) { // this.dataGridViewPagingSumCtrl.BindingDataSource<PfCustomerInvoicing>(DataGridViewUtil.ToDataTable<PfCustomerInvoicing>(listPage)); //set up columns List <PfInvoicingItem> customers = GetCostumerCount(listPage); List <DataGridViewColumn> columns = new List <DataGridViewColumn>(); if (view != null) { view.CellContentClick -= this.View1_CellContentClick; this.skinSplitContainer1.Panel1.Controls.Remove(view); view.Dispose(); dataGridViewPagingSumCtrl1.Dispose(); } view = new DataMergedView(); view.CellContentClick += this.View1_CellContentClick; view.Name = "autoView"; view.AllowUserToAddRows = false; view.AllowUserToDeleteRows = false; view.AllowUserToOrderColumns = true; view.AutoGenerateColumns = false; view.MultiSelect = false; view.ReadOnly = true; this.skinSplitContainer1.Panel1.Controls.Add(view); view.Dock = DockStyle.Fill; DataGridViewTextBoxColumn costumeID = new DataGridViewTextBoxColumn(); costumeID.DataPropertyName = "CostumeID"; view.Columns.Add(costumeID); costumeID.ValueType = typeof(String); costumeID.HeaderText = "款号"; DataGridViewTextBoxColumn costumeName = new DataGridViewTextBoxColumn(); costumeName.DataPropertyName = "CostumeName"; costumeName.ValueType = typeof(String); view.Columns.Add(costumeName); costumeName.HeaderText = "商品名称"; DataGridViewTextBoxColumn colorName = new DataGridViewTextBoxColumn(); colorName.DataPropertyName = "ColorName"; colorName.ValueType = typeof(String); view.Columns.Add(colorName); colorName.HeaderText = "颜色"; DataGridViewTextBoxColumn sizeName = new DataGridViewTextBoxColumn(); sizeName.DataPropertyName = "SizeName"; sizeName.HeaderText = "尺码"; sizeName.ValueType = typeof(String); view.Columns.Add(sizeName); DataGridViewTextBoxColumn delivery = new DataGridViewTextBoxColumn(); delivery.DataPropertyName = "Delivery"; delivery.ValueType = typeof(Int32); delivery.HeaderText = "发货"; columns.Add(delivery); view.Columns.Add(delivery); DataGridViewTextBoxColumn retail = new DataGridViewTextBoxColumn(); retail.DataPropertyName = "Retail"; retail.ValueType = typeof(Int32); retail.HeaderText = "销售"; view.Columns.Add(retail); columns.Add(retail); DataGridViewTextBoxColumn pfCustomerStore = new DataGridViewTextBoxColumn(); pfCustomerStore.DataPropertyName = "PfCustomerStore"; pfCustomerStore.HeaderText = "库存"; pfCustomerStore.ValueType = typeof(Int32); view.Columns.Add(pfCustomerStore); columns.Add(pfCustomerStore); for (int i = 0; i < customers.Count; i++) { DataGridViewLinkColumn Delivery = new DataGridViewLinkColumn(); Delivery.DataPropertyName = "Delivery" + i; Delivery.ValueType = typeof(Int32); Delivery.HeaderText = "发货"; columns.Add(Delivery); view.Columns.Add(Delivery); DataGridViewTextBoxColumn PfCustomerID = new DataGridViewTextBoxColumn(); PfCustomerID.DataPropertyName = "PfCustomerID" + i; PfCustomerID.HeaderText = "客户编号"; PfCustomerID.ValueType = typeof(String); PfCustomerID.Width = 1; PfCustomerID.Visible = false; view.Columns.Add(PfCustomerID); DataGridViewLinkColumn Retail = new DataGridViewLinkColumn(); Retail.DataPropertyName = "Retail" + i; Retail.ValueType = typeof(Int32); Retail.HeaderText = "销售"; view.Columns.Add(Retail); columns.Add(Retail); DataGridViewTextBoxColumn PfCustomerStore = new DataGridViewTextBoxColumn(); PfCustomerStore.DataPropertyName = "PfCustomerStore" + i; PfCustomerStore.HeaderText = "库存"; PfCustomerStore.ValueType = typeof(Int32); view.Columns.Add(PfCustomerStore); columns.Add(PfCustomerStore); //columns.Add(PfCustomerID); curControlList.Add(i); } //生成 datatable var dt = new DataTable(typeof(PfCustomerInvoicing).Name); foreach (DataGridViewColumn p in view.Columns) { dt.Columns.Add(new DataColumn(p.DataPropertyName, p.ValueType)); } foreach (PfCustomerInvoicing item in listPage) { ArrayList tempList = new ArrayList(); tempList.Add(item.CostumeID); tempList.Add(item.CostumeName); tempList.Add(item.ColorName); tempList.Add(item.SizeName); tempList.Add(item.Delivery); tempList.Add(item.Retail); tempList.Add(item.PfCustomerStore); if (item != null) { foreach (var customer in customers) { if (item.PfInvoicingItems != null) { PfInvoicingItem pfInvoicing = item.PfInvoicingItems.Find(t => customer.PfCustomerID == t.PfCustomerID); if (pfInvoicing != null) { tempList.Add(pfInvoicing.Delivery); tempList.Add(pfInvoicing.PfCustomerID); tempList.Add(pfInvoicing.Retail); tempList.Add(pfInvoicing.PfCustomerStore); } else { tempList.Add(0); tempList.Add(0); tempList.Add(0); tempList.Add(0); } } else { tempList.Add(0); tempList.Add(0); tempList.Add(0); tempList.Add(0); } } } object[] array = tempList.ToArray(); dt.LoadDataRow(array, true); } dataGridViewPagingSumCtrl1 = new DataGridViewPagingSumCtrl(view, DataGridViewPagingSumCtrl.GetColumnDataPropertyNames(columns)); dataGridViewPagingSumCtrl1.Initialize(); dataGridViewPagingSumCtrl1.BindingDataSource <DataTable>(dt); SetSpanInfo(customers); } else { this.dataGridViewPagingSumCtrl.BindingDataSource <PfCustomerInvoicing>(DataGridViewUtil.ToDataTable <PfCustomerInvoicing>(listPage)); } }