/// <summary> /// Save view open the Save view form to save the operation on datagridview. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveView_Click(object sender, EventArgs e) { try { SaveViewForm ccSaveViewFrm = new SaveViewForm(m_assetHistoryModel.m_DataContext, m_dataGridViewColumnSelector); ccSaveViewFrm.StartPosition = FormStartPosition.CenterParent; if (ccSaveViewFrm.ShowDialog(this) == DialogResult.OK) { LoadComboBox(); cmbNamedView.SelectedIndex = cmbNamedView.Items.Count - 1; if (m_dataGridViewColumnSelector != null) { m_dataGridViewColumnSelector.mSortedDataList = new List <ccSortedData>(); m_dataGridViewColumnSelector = new DataGridViewColumnSelector(dgHistory, m_assetHistoryModel); } } else { } } catch (Exception ex) { MessageBox.Show("Error during execution of Review Asset History custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Go button will load datagridview based on quer by group box data. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGo_Click(object sender, EventArgs e) { try { m_dataGridViewColumnSelector = null; LoadDatagridView(null); cmbNamedView.SelectedIndex = -1; m_dataGridViewColumnSelector = new DataGridViewColumnSelector(dgHistory, m_assetHistoryModel); if (dgHistory.Rows.Count > 0) { btnSaveView.Enabled = true; btnExport.Enabled = true; } else { btnSaveView.Enabled = false; btnExport.Enabled = false; } } catch (Exception ex) { MessageBox.Show("Error during execution of Review Asset History custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ReviewAssetHistoryForm(AssetHistoryModel assetHistoryModel, IGTTransactionManager oGTTransactionManager, IGTCustomCommandHelper GTCustomCommandHelper) { try { m_dataGridViewColumnSelector = null; m_assetHistoryModel = assetHistoryModel; m_oGTTransactionManager = oGTTransactionManager; m_GTCustomCommandHelper = GTCustomCommandHelper; InitializeComponent(); if (!assetHistoryModel.m_DataContext.IsRoleGranted("ADMINISTRATOR")) { btnSaveView.Visible = false; } if (m_assetHistoryModel.m_FID != 0 && !m_assetHistoryModel.m_isStructure) { txtFid.Text = Convert.ToString(m_assetHistoryModel.m_FID); } LoadDatagridView(null); LoadComboBox(); cmbNamedView.SelectedIndex = -1; m_dataGridViewColumnSelector = new DataGridViewColumnSelector(dgHistory, m_assetHistoryModel); if (dgHistory.Rows.Count > 0) { btnSaveView.Enabled = true; btnExport.Enabled = true; } else { btnSaveView.Enabled = false; btnExport.Enabled = false; } } catch (Exception ex) { MessageBox.Show("Error during execution of Review Asset History custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Release all objects / all instances and dispose datagridview and the datatable. /// </summary> private void CloseForm() { try { dgvReviewHistory.Dispose(); m_dataGridViewColumnSelector = null; if (m_assetHistoryModel.m_GridDataTable != null) { m_assetHistoryModel.m_GridDataTable.Dispose(); } m_assetHistoryModel.ExitCommand(m_oGTTransactionManager, m_GTCustomCommandHelper); m_assetHistoryModel = null; this.Close(); } catch { throw; } }
public SaveViewForm(IGTDataContext gTDataContext, DataGridViewColumnSelector dataGridViewColumnSelector) { InitializeComponent(); m_gTDataContext = gTDataContext; m_dataGridViewColumnSelector = dataGridViewColumnSelector; }
/// <summary> /// Combobox event: It will apply the saved filters and sorted column order on the current datagridview based on combo box value. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbNamedView_SelectedIndexChanged(object sender, EventArgs e) { string strFilterExp = ""; string strSortOrder = ""; DataView dv; Recordset rs = null; short viewId = 0; try { if (m_dataGridViewColumnSelector != null) { m_dataGridViewColumnSelector = null; m_dataGridViewColumnSelector = new DataGridViewColumnSelector(dgHistory, m_assetHistoryModel); } //LoadDatagridView(null); if (cmbNamedView.SelectedItem != null) { viewId = Convert.ToInt16((cmbNamedView.SelectedItem as dynamic).Value); } if (viewId != 0) { //dv = m_assetHistoryModel.m_GridDataTable.DefaultView; dv = m_assetHistoryModel.LoadGridData().DefaultView; rs = ExecuteCommand(string.Format("select FILTER_COLUMN,FILTER_VALUE from asset_history_viewfilter where view_id= {0}", viewId)); if (rs != null && rs.RecordCount > 0) { strFilterExp = GetFiltersExpressionOfView(strFilterExp, rs); } rs = null; rs = ExecuteCommand(string.Format("select SORT_COLUMN,SORT_DIRECTION,SORT_PRIORITY from ASSET_HISTORY_VIEWSORT where VIEW_ID={0} order by SORT_PRIORITY", viewId)); if (rs != null && rs.RecordCount > 0) { strSortOrder = GetSortOrderExpressionOfView(strSortOrder, rs); } if (!string.IsNullOrEmpty(strFilterExp)) { dv.RowFilter = strFilterExp; } if (!string.IsNullOrEmpty(strSortOrder)) { dv.Sort = strSortOrder; } if (!string.IsNullOrEmpty(strSortOrder) || !string.IsNullOrEmpty(strFilterExp)) { LoadDatagridView(dv); } else if (string.IsNullOrEmpty(strSortOrder) && string.IsNullOrEmpty(strFilterExp)) { LoadDatagridView(null); } } if (dgHistory.Rows.Count > 0) { btnSaveView.Enabled = true; btnExport.Enabled = true; } else { btnSaveView.Enabled = false; btnExport.Enabled = false; } } catch (Exception ex) { MessageBox.Show("Error during execution of Review Asset History custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (rs != null) { if (rs.State == 1) { rs.Close(); rs.ActiveConnection = null; } rs = null; } } }