protected void DeleteRow(int rowIndex)
    {
        GridViewRow row       = grid.Rows[rowIndex];
        var         newValues = this.GetValues(row);

        connec = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + GetDirectory() + userDir + MAIN_USER_DATABASE + ";");
        OleDbCommand cmd = new OleDbCommand(GetCommandString(Command.DELETE), connec);

        cmd.Parameters.AddWithValue(FIELDS[0], grid.DataKeys[row.RowIndex][FIELDS[0]]);

        int key = int.Parse(grid.DataKeys[row.RowIndex][FIELDS[0]].ToString());

        try
        {
            int    prodid = -1;
            string opname = "";
            bool   issueRoutingWarning = false;
            ClassF classA = null;
            if (TABLE_NAME.Equals("tbloper"))
            {
                try
                {
                    prodid = int.Parse(GetDatabaseField("Prodfore", "OpID", key, "tblOper"));
                    opname = GetDatabaseField("OpNam", "OpID", key, "tblOper");
                    try
                    {
                        classA = new ClassF(GetDirectory() + userDir);
                        issueRoutingWarning = classA.repair_routings(key, opname, prodid);
                        classA.Close();
                    }
                    catch (Exception) { }
                }
                catch (Exception) { }
            }
            connec.Open();
            try
            {
                int result = cmd.ExecuteNonQuery();
            }
            catch (Exception excep)
            {
                Exception excepNew = new Exception("Error in executing delete query. Command string: " + cmd.CommandText + ". Exception message: " + excep.Message, excep);
                throw excepNew;
            }
            connec.Close();

            grid.EditIndex = -1;
            this.SetData();

            if (classA == null)
            {
                classA = new ClassF(GetDirectory() + userDir);
            }
            else
            {
                classA.Open();
            }

            if (TABLE_NAME.Equals("tbllabor"))
            {
                classA.del_labor_res(key);
                classA.del_lab_ref(key);
            }
            else if (TABLE_NAME.Equals("tblequip"))
            {
                classA.del_eq_res(key);
                classA.del_eq_ref(key);
            }
            else if (TABLE_NAME.Equals("tblprodfore"))
            {
                classA.del_pt_res(key);
            }
            else if (TABLE_NAME.Equals("tbloper"))
            {
                // delete oper results ??? ask Greg
                classA.del_op_res(key);
            }
            classA.Close();
            if (TABLE_NAME.Equals("tbloper"))
            {
                tableSync.UpdateOpNumbers();
            }

            if (issueRoutingWarning)
            {
                Master.ShowInfoMessage("Routings for the operation were deleted. Please check out '" + opname + "' routing deleted does not leave a hole in the routings.");
            }
        }
        catch (Exception ex)
        {
            logFiles.ErrorLog(ex);
            try
            {
                connec.Close();
                connec = null;
            }
            catch { }
            Master.ShowErrorMessage("An error has occured and the record could not get deleted.");
        }
    }