private DataGridView gridView; // элемент управления таблицы, в которой производится замена /// <summary> /// Конструктор /// </summary> public FrmReplace() { InitializeComponent(); completeMsg = AppPhrases.ValueNotFound; frmTable = null; gridView = null; }
/// <summary> /// Create a table editing form /// </summary> private FrmTable NewTableForm(string text, DataTable table) { var frmTable = new FrmTable(); frmTable.Text = text; frmTable.Table = table; return(frmTable); }
private DataGridView gridView; // элемент управления таблицы, в которой производится замена #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> public FrmReplace() { InitializeComponent(); completeMsg = AppPhrases.ValueNotFound; frmTable = null; gridView = null; }
private void miEditPaste_Click(object sender, EventArgs e) { FrmTable frmTable = winControl.ActiveForm as FrmTable; if (frmTable != null) { frmTable.CellPaste(); } }
private void miInCnlProps_Click(object sender, EventArgs e) { FrmInCnlProps frmInCnlProps = new FrmInCnlProps(); FrmTable frmTable = winControl.ActiveForm as FrmTable; if (frmTable != null && frmInCnlProps.ShowInCnlProps(frmTable) == DialogResult.OK) { frmTable.UpdateTable(); } }
private void miDbExport_Click(object sender, EventArgs e) { // создание и отоборажение формы экспорта таблицы FrmExport frmExport = new FrmExport(); FrmTable frmTable = winControl.ActiveForm as FrmTable; if (frmTable != null && frmTable.Table != null) { frmExport.DefaultTableName = frmTable.Table.TableName; } frmExport.DefaultDirectory = settings.AppSett.BaseDATDir; frmExport.ShowDialog(); }
/// <summary> /// Подготовить к закрытию все дочерние формы /// </summary> private void PrepareCloseAll(bool showError) { List <Form> forms = winControl.Forms; foreach (Form form in forms) { FrmTable frmTable = form as FrmTable; if (frmTable != null) { frmTable.PrepareClose(showError); } } }
private void miWindowCloseActive_Click(object sender, EventArgs e) { FrmTable frmTable = winControl.ActiveForm as FrmTable; if (frmTable != null) { frmTable.PrepareClose(true); bool cancel; winControl.CloseForm(frmTable, out cancel); if (!cancel) { SetItemsEnabledOnWindowAction(); } } }
private void miWindowCloseAllButActive_Click(object sender, EventArgs e) { // подготовка форм к закрытию List <Form> forms = winControl.Forms; foreach (Form form in forms) { if (form != winControl.ActiveForm) { FrmTable frmTable = form as FrmTable; if (frmTable != null) { frmTable.PrepareClose(true); } } } // закрытие форм bool cancel; winControl.CloseAllButActive(out cancel); }
/// <summary> /// Отобразить свойства входного канала /// </summary> public DialogResult ShowInCnlProps(FrmTable frmTable) { // получение редактируемой таблицы и строки this.frmTable = frmTable; try { gridView = frmTable.GridView; row = gridView.Rows[gridView.CurrentCell.RowIndex]; } catch { gridView = null; row = null; } // отображение свойств выбранного входного канала try { if (row == null) throw new Exception(CommonPhrases.NoData); chkActive.Checked = ObjToBool(row.Cells["Active"].Value); txtModifiedDT.Text = row.Cells["ModifiedDT"].FormattedValue.ToString(); txtCnlNum.Text = row.Cells["CnlNum"].FormattedValue.ToString(); txtName.Text = row.Cells["Name"].FormattedValue.ToString(); SetComboBoxVal(cbCnlType, "CnlTypeID"); SetComboBoxVal(cbObj, "ObjNum"); if (cbObj.SelectedValue != null) txtObjNum.Text = cbObj.SelectedValue.ToString(); SetComboBoxVal(cbKP, "KPNum"); if (cbKP.SelectedValue != null) txtKPNum.Text = cbKP.SelectedValue.ToString(); txtSignal.Text = row.Cells["Signal"].FormattedValue.ToString(); chkFormulaUsed.Checked = ObjToBool(row.Cells["FormulaUsed"].Value); txtFormula.Text = row.Cells["Formula"].FormattedValue.ToString(); SetComboBoxVal(cbParam, "ParamID"); SetComboBoxVal(cbFormat, "FormatID"); SetComboBoxVal(cbUnit, "UnitID"); object numObj = row.Cells["CtrlCnlNum"].Value; if (numObj is int) { int num = (int)numObj; txtCtrlCnlNum.Text = num.ToString(); txtCtrlCnlName.Text = Tables.GetCtrlCnlName(num); } chkEvEnabled.Checked = ObjToBool(row.Cells["EvEnabled"].Value); chkEvSound.Checked = ObjToBool(row.Cells["EvSound"].Value); chkEvOnChange.Checked = ObjToBool(row.Cells["EvOnChange"].Value); chkEvOnUndef.Checked = ObjToBool(row.Cells["EvOnUndef"].Value); txtLimLowCrash.Text = row.Cells["LimLowCrash"].FormattedValue.ToString(); txtLimLow.Text = row.Cells["LimLow"].FormattedValue.ToString(); txtLimHigh.Text = row.Cells["LimHigh"].FormattedValue.ToString(); txtLimHighCrash.Text = row.Cells["LimHighCrash"].FormattedValue.ToString(); return ShowDialog(); } catch (Exception ex) { AppUtils.ProcError(AppPhrases.ShowInCnlPropsError + ":\r\n" + ex.Message); return DialogResult.Cancel; } }
/// <summary> /// Perform an action associated with a tree node /// </summary> private void ExecNodeAction(TreeNode node) { var nodeInfo = node.Tag as NodeInfo; if (nodeInfo != null) { if (nodeInfo.Form == null) { FrmTable frmTable = null; var imageKey = "table.gif"; try { int param = -1; object[] paramArr = nodeInfo.Params; if (paramArr != null && paramArr.Length > 0 && paramArr[0] is int) { param = (int)paramArr[0]; } string nodeText = node.Text; switch (nodeInfo.NodeAction) { case NodeActions.Obj: frmTable = NewTableForm(nodeText, Tables.GetObjTable()); break; case NodeActions.CommLine: frmTable = NewTableForm(nodeText, Tables.GetCommLineTable()); break; case NodeActions.KP: frmTable = NewTableForm(nodeText, Tables.GetKPTable()); break; case NodeActions.InCnl: frmTable = NewTableForm(nodeText, Tables.GetInCnlTable()); frmTable.GridContextMenu = contextInCnls; break; case NodeActions.InCnlObj: frmTable = NewTableForm(CommonPhrases.InCnlTable + " - " + nodeText, Tables.GetInCnlTableByObjNum(param)); frmTable.GridContextMenu = contextInCnls; imageKey = "object.gif"; break; case NodeActions.InCnlKP: frmTable = NewTableForm(CommonPhrases.InCnlTable + " - " + nodeText, Tables.GetInCnlTableByKPNum(param)); frmTable.GridContextMenu = contextInCnls; imageKey = "kp.gif"; break; case NodeActions.CtrlCnl: frmTable = NewTableForm(nodeText, Tables.GetCtrlCnlTable()); break; case NodeActions.CtrlCnlObj: frmTable = NewTableForm(CommonPhrases.CtrlCnlTable + " - " + nodeText, Tables.GetCtrlCnlTableByObjNum(param)); imageKey = "object.gif"; break; case NodeActions.CtrlCnlKP: frmTable = NewTableForm(CommonPhrases.CtrlCnlTable + " - " + nodeText, Tables.GetCtrlCnlTableByKPNum(param)); imageKey = "kp.gif"; break; case NodeActions.Role: frmTable = NewTableForm(nodeText, Tables.GetRoleTable()); break; case NodeActions.User: frmTable = NewTableForm(nodeText, Tables.GetUserTable()); break; case NodeActions.Interface: frmTable = NewTableForm(nodeText, Tables.GetInterfaceTable()); break; case NodeActions.Right: frmTable = NewTableForm(nodeText, Tables.GetRightTable()); break; case NodeActions.CnlType: frmTable = NewTableForm(nodeText, Tables.GetCnlTypeTable()); break; case NodeActions.CmdType: frmTable = NewTableForm(nodeText, Tables.GetCmdTypeTable()); break; case NodeActions.EvType: frmTable = NewTableForm(nodeText, Tables.GetEvTypeTable()); break; case NodeActions.KPType: frmTable = NewTableForm(nodeText, Tables.GetKPTypeTable()); break; case NodeActions.Param: frmTable = NewTableForm(nodeText, Tables.GetParamTable()); break; case NodeActions.Unit: frmTable = NewTableForm(nodeText, Tables.GetUnitTable()); break; case NodeActions.CmdVal: frmTable = NewTableForm(nodeText, Tables.GetCmdValTable()); break; case NodeActions.Format: frmTable = NewTableForm(nodeText, Tables.GetFormatTable()); break; case NodeActions.Formula: frmTable = NewTableForm(nodeText, Tables.GetFormulaTable()); break; } } catch (Exception ex) { AppUtils.ProcError(ex.Message); frmTable = null; } if (frmTable != null) { frmTable.FormClosed += ChildFormClosed; nodeInfo.Form = frmTable; winControl.AddForm(frmTable, "", ilTree.Images[imageKey], node); } } else { winControl.ActivateForm(nodeInfo.Form); } SetItemsEnabledOnWindowAction(); } }
/// <summary> /// Display Input Channel Properties /// </summary> public DialogResult ShowInCnlProps(FrmTable frmTable) { // getting editable table and row this.frmTable = frmTable; try { gridView = frmTable.GridView; row = gridView.Rows[gridView.CurrentCell.RowIndex]; } catch { gridView = null; row = null; } // display properties of the selected input channel try { if (row == null) { throw new Exception(CommonPhrases.NoData); } chkActive.Checked = ObjToBool(row.Cells["Active"].Value); txtModifiedDT.Text = row.Cells["ModifiedDT"].FormattedValue.ToString(); txtCnlNum.Text = row.Cells["CnlNum"].FormattedValue.ToString(); txtName.Text = row.Cells["Name"].FormattedValue.ToString(); SetComboBoxVal(cbCnlType, "CnlTypeID"); SetComboBoxVal(cbObj, "ObjNum"); if (cbObj.SelectedValue != null) { txtObjNum.Text = cbObj.SelectedValue.ToString(); } SetComboBoxVal(cbKP, "KPNum"); if (cbKP.SelectedValue != null) { txtKPNum.Text = cbKP.SelectedValue.ToString(); } txtSignal.Text = row.Cells["Signal"].FormattedValue.ToString(); chkFormulaUsed.Checked = ObjToBool(row.Cells["FormulaUsed"].Value); txtFormula.Text = row.Cells["Formula"].FormattedValue.ToString(); SetComboBoxVal(cbParam, "ParamID"); SetComboBoxVal(cbFormat, "FormatID"); SetComboBoxVal(cbUnit, "UnitID"); var numObj = row.Cells["CtrlCnlNum"].Value; if (numObj is int) { var num = (int)numObj; txtCtrlCnlNum.Text = num.ToString(); txtCtrlCnlName.Text = Tables.GetCtrlCnlName(num); } chkEvEnabled.Checked = ObjToBool(row.Cells["EvEnabled"].Value); chkEvSound.Checked = ObjToBool(row.Cells["EvSound"].Value); chkEvOnChange.Checked = ObjToBool(row.Cells["EvOnChange"].Value); chkEvOnUndef.Checked = ObjToBool(row.Cells["EvOnUndef"].Value); txtLimLowCrash.Text = row.Cells["LimLowCrash"].FormattedValue.ToString(); txtLimLow.Text = row.Cells["LimLow"].FormattedValue.ToString(); txtLimHigh.Text = row.Cells["LimHigh"].FormattedValue.ToString(); txtLimHighCrash.Text = row.Cells["LimHighCrash"].FormattedValue.ToString(); return(ShowDialog()); } catch (Exception ex) { AppUtils.ProcError(AppPhrases.ShowInCnlPropsError + ":\r\n" + ex.Message); return(DialogResult.Cancel); } }
/// <summary> /// Создать форму редактирования таблицы /// </summary> private FrmTable NewTableForm(string text, DataTable table) { FrmTable frmTable = new FrmTable(); frmTable.Text = text; frmTable.Table = table; return frmTable; }