private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } if (e.ColumnIndex == 0) { //編輯 //DataGridViewButtonCell clickedButtonCell = (DataGridViewButtonCell)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; int colIndex = this.dataGridView1.GetColumnIndex("料件編號"); string pn = dataGridView1.Rows[e.RowIndex].Cells[colIndex].Value.ToString(); colIndex = this.dataGridView1.GetColumnIndex("採購數量"); string qty = dataGridView1.Rows[e.RowIndex].Cells[colIndex].Value.ToString(); colIndex = this.dataGridView1.GetColumnIndex("SourceListOID"); int sl = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[colIndex].Value); POSetQtyForm frm = new POSetQtyForm { CmdMode = POSetQtyForm.CommandMode.Edit, PartNumber = pn, Qty = qty, SourceListOID = sl, ListIndex = e.RowIndex }; Common.ContainerForm.NextForm(frm); } else if (e.ColumnIndex == 1) { //刪除 PurchasingOrderUtil.GetPurchasingOrderDetail().RemoveAt(e.RowIndex); this.Init(); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != 0 || e.RowIndex == -1) { return; } int colIndex = this.dataGridView1.GetColumnIndex("料件編號"); string partNumber = this.dataGridView1.Rows[e.RowIndex].Cells[colIndex].Value.ToString(); //Util.SetSessionValue("PartNumber", partNumber); POSetQtyForm frm = new POSetQtyForm(); frm.CmdMode = POSetQtyForm.CommandMode.Add; frm.PartNumber = partNumber; Common.ContainerForm.NextForm(frm); }