void SetShowData(string pn) { //string partNumber = Convert.ToString(Util.GetSessionValueThenRemove("PartNumber")); PartDao pDao = new PartDao(); this.PartData = pDao.FindPartByPartNumber(pn); this.lblPartNumber.Text = PartData.PartNumber; this.lblPartName.Text = PartData.PartName; this.lblPartSpec.Text = PartData.PartSpec; this.lblUnitPrice.Text = PartData.UnitPrice.ToString(); this.lblSupplierName.Text = PartData.GetSupplierInfo().SupplierName; SourceListDao slDao = new SourceListDao(); this.sourceLists = slDao.FindSourceListByPartNumber(PartData.PartNumber); var q = from sl in sourceLists select new { Value = sl.SourceListOID, Display = $"批量:{sl.Batch,4} - 折扣:{Math.Round(sl.Discount * 10, 1)}折 - 單價:{Math.Round(PartData.UnitPrice.Value * sl.Batch * sl.Discount, 0)}" }; this.cbSourceList.DataSource = q.ToList(); this.cbSourceList.DisplayMember = "Display"; this.cbSourceList.ValueMember = "Value"; }
private void btnSearch_Click(object sender, EventArgs e) { this.dataGridView1.Columns.Clear(); PartDao dao = new PartDao(); DataTable dt = dao.FindPartForPickup(this.txtPartNumber.Text.Trim(), this.txtPartName.Text.Trim()); if (dt.Rows.Count > 0) { DataGridViewButtonColumn btnPickup = new DataGridViewButtonColumn(); btnPickup.HeaderText = "動作"; btnPickup.Text = "選取"; btnPickup.Name = "btnPickup"; btnPickup.UseColumnTextForButtonValue = true; dataGridView1.Columns.Insert(0, btnPickup); } else { MessageBox.Show("查詢無資料"); } this.dataGridView1.DataSource = dt; }