private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } try { if (e.ColumnIndex == 4) { clearDocumentData(); prevdoc = new doccommenter(); int rowID = e.RowIndex; btnSave.Text = "Update"; pnlDocumentInner.Visible = true; pnlDocumentOuter.Visible = true; pnlDocumentList.Visible = false; prevdoc.DocumentID = grdList.Rows[e.RowIndex].Cells[0].Value.ToString(); prevdoc.EmployeeID = grdList.Rows[e.RowIndex].Cells[2].Value.ToString().Substring(grdList.Rows[e.RowIndex].Cells[2].Value.ToString().Trim().IndexOf('-') + 1); ////cmbDocument.SelectedIndex = cmbDocument.FindStringExact(grdList.Rows[e.RowIndex].Cells[0].Value.ToString() + "-" + grdList.Rows[e.RowIndex].Cells[1].Value.ToString()); cmbDocument.SelectedIndex = Structures.ComboFUnctions.getComboIndex(cmbDocument, grdList.Rows[e.RowIndex].Cells[0].Value.ToString()); cmbEmployee.SelectedIndex = cmbEmployee.FindStringExact(grdList.Rows[e.RowIndex].Cells[2].Value.ToString()); cmbDocumentStatus.SelectedIndex = cmbDocumentStatus.FindStringExact(grdList.Rows[e.RowIndex].Cells[3].Value.ToString()); cmbDocument.Enabled = false; disableBottomButtons(); } } catch (Exception) { } }
public void clearDocumentData() { try { cmbDocumentStatus.SelectedIndex = -1; cmbEmployee.SelectedIndex = -1; prevdoc = new doccommenter(); } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { try { doccommenter doc = new doccommenter(); DocCommenterDB docDB = new DocCommenterDB(); try { ////////doc.DocumentID = cmbDocument.SelectedItem.ToString().Trim().Substring(0, cmbDocument.SelectedItem.ToString().Trim().IndexOf('-')); doc.DocumentID = ((Structures.ComboBoxItem)cmbDocument.SelectedItem).HiddenValue; ////doc.DocumentName = cmbDocument.SelectedItem.ToString().Trim().Substring(cmbDocument.SelectedItem.ToString().Trim().IndexOf('-') + 1); doc.DocumentName = ((Structures.ComboBoxItem)cmbDocument.SelectedItem).ToString(); doc.EmployeeName = cmbEmployee.SelectedItem.ToString().Trim().Substring(0, cmbEmployee.SelectedItem.ToString().Trim().IndexOf('-')); doc.EmployeeID = cmbEmployee.SelectedItem.ToString().Trim().Substring(cmbEmployee.SelectedItem.ToString().Trim().IndexOf('-') + 1); } catch (Exception) { doc.DocumentID = ""; doc.DocumentName = ""; doc.EmployeeName = ""; doc.EmployeeID = ""; } doc.DocumentStatus = ComboFIll.getStatusCode(cmbDocumentStatus.SelectedItem.ToString()); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; { if (btnText.Equals("Update")) { if (docDB.updateDocCommList(doc, prevdoc)) { MessageBox.Show("DocEmpMapping Status updated"); closeAllPanels(); ListDocCommentor(); } else { MessageBox.Show("Failed to update DocEmpMapping Status"); } } else if (btnText.Equals("Save")) { if (docDB.validateDocument(doc)) { if (docDB.insertDocCommList(doc)) { MessageBox.Show("DocEmpMapping data Added"); closeAllPanels(); ListDocCommentor(); } else { MessageBox.Show("Failed to Insert DocEmpMapping"); } } else { MessageBox.Show("DocEmpMapping Data Validation failed"); } } } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } }