long _lngPKID = 0; // Primary key variable set it to 0 #endregion #region Constructor /// <summary> /// load the query that has been passed to the first parameter value /// and place it in a datatable /// </summary> /// <param name="pStrQuery"></param> /// <param name="pDtb"></param> public FrmPermissions(String pStrQuery, DataTable pDtb) { InitializeComponent(); _permission = new Permission(); // create a new instance pDtb = _dbConn.GetDataTable(pStrQuery); // get the current query and place it into the datatable dgvData.DataSource = pDtb; // display datatable in the datagrid view dgvData.Columns[0].Visible = false; // set the first row to invisible populateEmployeeCombo(); //populate the employee combo box populateFormsCombo(); // populate the forms combo box _dtb = pDtb; // set the global value to the paremeter value _strQuery = pStrQuery; // set the global variable to the parameter value }
private void dgvData_Click(object sender, EventArgs e) { mnuSave.Enabled = false; ErrorProvider.Dispose(); // if there is an id value in this current row if (dgvData["EmployeeFormID", dgvData.CurrentCell.RowIndex].Value.ToString() != string.Empty) { // give the primary key variable the current id of the current row selected _lngPKID = long.Parse(dgvData["EmployeeFormID", dgvData.CurrentCell.RowIndex].Value.ToString()); _permission = new Permission(_lngPKID); // create a new instance of the permission but pass it the id displayRecord(); // display the current record groupBox1.Enabled = true; groupBox2.Enabled = true; groupBox3.Enabled = true; groupBox4.Enabled = true; mnuSave.Enabled = true; } }
private void dgvData_DoubleClick(object sender, EventArgs e) { // the there are no id values in this current row if (dgvData["EmployeeFormID", dgvData.CurrentCell.RowIndex].Value.ToString() == string.Empty) { _lngPKID = 0; // set the primary key to 0 clearFields(); // clear the fields _permission = new Permission(); // and make a new instance of permissions groupBox1.Enabled = true; groupBox2.Enabled = true; groupBox3.Enabled = true; groupBox4.Enabled = true; } }