private void resultsGrid_dg_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { //this.Visible = false; //if (sender != null) //{ // string key = ((DataGridView)(sender)).CurrentRow.Cells["ICN"].Value.ToString(); // _theData.Tables["MDSE"].DefaultView.RowFilter = "ICN='" + key + "'"; //} DataView dv = _theData.DefaultViewManager.CreateDataView(_theData.Tables["MDSE"]); dv.Sort = _theData.Tables["MDSE"].DefaultView.Sort; Form details = new ItemDetails(dv, e.RowIndex); details.ShowDialog(); switch (details.DialogResult) { case DialogResult.OK: this.Visible = true; break; default: this.DialogResult = details.DialogResult; this.Close(); break; } } }
private void button2_Click(object sender, System.EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("Please select an item to edit."); return; } else { int matID = 0; int rowID = dataGridView1.SelectedRows[0].Index; foreach (DataGridViewRow item in dataGridView1.SelectedRows) { foreach (MaterialInfo material in currentMaterialList) { string name = material.name; if (material.type.ToLower() != "none" && material.type != "") { name += " (" + material.type + ")"; } if (name == item.Cells[0].Value.ToString()) { matID = currentMaterialList.IndexOf(material); break; } } } ItemDetails newForm = new ItemDetails(currentMaterialList[matID]); DialogResult editItem = newForm.ShowDialog(); if (editItem == DialogResult.OK) { MaterialInfo editedItem = newForm.editItem; libraryManager.notifyUpdate(editedItem); string name = editedItem.name; string type = editedItem.type; string author = editedItem.author; string publisher = editedItem.publisher; int stock = editedItem.itemcount; DateTime date = editedItem.publishDate; currentMaterialList[matID].update(name, author, publisher, date, stock, type); dataGridView1.Rows[rowID].Cells[0].Value = name; dataGridView1.Rows[rowID].Cells[1].Value = author; dataGridView1.Rows[rowID].Cells[2].Value = publisher; if (currentMaterialList[matID].isFile == false) { dataGridView1.Rows[rowID].Cells[3].Value = stock; } dataGridView1.Update(); dataGridView1.Refresh(); } newForm.Dispose(); return; } }
private void ItemsList_dg_CellContentClick(object sender, DataGridViewCellEventArgs e) { var key = _selectedData[_rowNum].Row.Field <int>("TICKET_NUMBER"); try { if (e.ColumnIndex == 0) { this.Visible = false; DataView itemView = _dataSet.DefaultViewManager.CreateDataView(_selectedData.Table); itemView.RowFilter = "TICKET_NUMBER=" + key + ""; Form details = new ItemDetails(itemView, e.RowIndex); details.ShowDialog(); switch (details.DialogResult) { case DialogResult.OK: this.Visible = true; break; default: this.DialogResult = details.DialogResult; this.Close(); break; } } } catch (Exception) { this.Visible = true; MessageBox.Show("Unable to display data for " + key.ToString()); } }