private void btnQryProduct_Click(object sender, EventArgs e) { TListProductID SelectProductID = new TListProductID(); productIDTextBox.Text = SelectProductID.ProductID; productIDTextBox.Focus(); }
private void deliveryDetailsDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (TBStatus == 0) { return; } DataGridView Grid = deliveryDetailsDataGridView; if (Grid.Columns[e.ColumnIndex].Name == "colProductID") { string strProductID; strProductID = e.FormattedValue.ToString(); //判斷是否有輸入商品編號 if (string.IsNullOrEmpty(e.FormattedValue.ToString())) { //沒有輸入商品編號,帶出商品編號挑選視窗 //檢查目前DataGridView控制項是不是還具有焦點 if (blnEnterGrid) { TListProductID SelectProductID = new TListProductID(); strProductID = SelectProductID.ProductID; //取得所挑選的商品編號 Grid.Rows[e.RowIndex].Cells["colProductID"].Value = strProductID; Grid.Rows[e.RowIndex].Cells["colProductID"].Selected = true; } } //檢查商品編號是否輸入正確 if (XIN.CheckProductID(strProductID)) { e.Cancel = false; } else { e.Cancel = true; } } int I = 0; //數量檢查 if (Grid.Columns[e.ColumnIndex].Name == "colQuantity") { if ((!int.TryParse(e.FormattedValue.ToString(), out I)) || (I < 0)) { MessageBox.Show("數量必須大於0!", "輸入錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); e.Cancel = true; } } //單價檢查 if (Grid.Columns[e.ColumnIndex].Name == "colUnitPrice") { if ((!int.TryParse(e.FormattedValue.ToString(), out I)) || (I < 0)) { MessageBox.Show("單價不可小於0!", "輸入錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); e.Cancel = true; } } }