Ejemplo n.º 1
0
        /// <summary>
        /// Импорт КП
        /// </summary>
        public static DialogResult Import(DataTable tblKP, int commLineNum, Log errLog, out FrmImport frmImport)
        {
            frmImport = null;

            try
            {
                tblKP.DefaultView.RowFilter = "CommLineNum = " + commLineNum;
                tblKP.DefaultView.Sort      = "KPNum";

                if (tblKP.DefaultView.Count == 0)
                {
                    ScadaUtils.ShowInfo(AppPhrases.NoImportData);
                    return(DialogResult.Cancel);
                }
                else
                {
                    // заполнение дерева импортируемых данных: только КП
                    frmImport             = new FrmImport();
                    frmImport.commLineNum = commLineNum;
                    TreeView treeView = frmImport.TreeView;
                    treeView.ShowRootLines = false;

                    try
                    {
                        treeView.BeginUpdate();
                        treeView.Nodes.Clear();

                        foreach (DataRowView rowKP in tblKP.DefaultView)
                        {
                            TreeNode nodeKP = new TreeNode(Settings.KP.GetCaption((int)rowKP["KPNum"], rowKP["Name"]));
                            nodeKP.Tag = rowKP;
                            treeView.Nodes.Add(nodeKP);
                        }
                    }
                    finally
                    {
                        treeView.EndUpdate();
                    }

                    // отображение формы импорта
                    return(frmImport.ShowDialog());
                }
            }
            catch (Exception ex)
            {
                string errMsg = AppPhrases.PrepareImportFormError2 + ":\r\n" + ex.Message;
                errLog.WriteAction(errMsg);
                ScadaUtils.ShowError(errMsg);

                return(DialogResult.Abort);
            }
            finally
            {
                try { tblKP.DefaultView.RowFilter = ""; }
                catch { }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Импорт линий связи и КП
        /// </summary>
        public static DialogResult Import(DataTable tblCommLine, DataTable tblKP, Log errLog, out FrmImport frmImport)
        {
            frmImport = null;

            try
            {
                if (tblCommLine.DefaultView.Count == 0)
                {
                    ScadaUtils.ShowInfo(AppPhrases.NoImportData);
                    return DialogResult.Cancel;
                }
                else
                {
                    // заполнение дерева импортируемых данных: линий связи и КП
                    frmImport = new FrmImport();
                    TreeView treeView = frmImport.TreeView;

                    try
                    {
                        treeView.BeginUpdate();
                        treeView.Nodes.Clear();

                        tblCommLine.DefaultView.Sort = "CommLineNum";
                        tblKP.DefaultView.Sort = "CommLineNum, KPNum";
                        int kpCnt = tblKP.DefaultView.Count;
                        int kpInd = 0;

                        foreach (DataRowView rowLine in tblCommLine.DefaultView)
                        {
                            int lineNum = (int)rowLine["CommLineNum"];
                            TreeNode nodeLine = new TreeNode(Settings.CommLine.GetCaption(lineNum, rowLine["Name"]));
                            nodeLine.Tag = rowLine;
                            treeView.Nodes.Add(nodeLine);

                            DataRowView rowKP = kpInd < kpCnt ? tblKP.DefaultView[kpInd] : null;
                            int kpLineNum = rowKP == null ? -1 : (int)rowKP["CommLineNum"];

                            while (0 <= kpLineNum && kpLineNum <= lineNum)
                            {
                                if (kpLineNum == lineNum)
                                {
                                    TreeNode nodeKP = 
                                        new TreeNode(Settings.KP.GetCaption((int)rowKP["KPNum"], rowKP["Name"]));
                                    nodeKP.Tag = rowKP;
                                    nodeLine.Nodes.Add(nodeKP);
                                }

                                kpInd++;
                                rowKP = kpInd < kpCnt ? tblKP.DefaultView[kpInd] : null;
                                kpLineNum = rowKP == null ? -1 : (int)rowKP["CommLineNum"];
                            }
                        }
                    }
                    finally
                    {
                        treeView.EndUpdate();
                    }

                    // отображение формы импорта
                    return frmImport.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                string errMsg = AppPhrases.PrepareImportFormError1 + ":\r\n" + ex.Message;
                errLog.WriteAction(errMsg);
                ScadaUtils.ShowError(errMsg);

                return DialogResult.Abort;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Импорт КП
        /// </summary>
        public static DialogResult Import(DataTable tblKP, int commLineNum, Log errLog, out FrmImport frmImport)
        {
            frmImport = null;

            try
            {
                tblKP.DefaultView.RowFilter = "CommLineNum = " + commLineNum;
                tblKP.DefaultView.Sort = "KPNum";

                if (tblKP.DefaultView.Count == 0)
                {
                    ScadaUtils.ShowInfo(AppPhrases.NoImportData);
                    return DialogResult.Cancel;
                }
                else
                {
                    // заполнение дерева импортируемых данных: только КП
                    frmImport = new FrmImport();
                    frmImport.commLineNum = commLineNum;
                    TreeView treeView = frmImport.TreeView;
                    treeView.ShowRootLines = false;

                    try
                    {
                        treeView.BeginUpdate();
                        treeView.Nodes.Clear();

                        foreach (DataRowView rowKP in tblKP.DefaultView)
                        {
                            TreeNode nodeKP = new TreeNode(Settings.KP.GetCaption((int)rowKP["KPNum"], rowKP["Name"]));
                            nodeKP.Tag = rowKP;
                            treeView.Nodes.Add(nodeKP);
                        }
                    }
                    finally
                    {
                        treeView.EndUpdate();
                    }

                    // отображение формы импорта
                    return frmImport.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                string errMsg = AppPhrases.PrepareImportFormError2 + ":\r\n" + ex.Message;
                errLog.WriteAction(errMsg);
                ScadaUtils.ShowError(errMsg);

                return DialogResult.Abort;
            }
            finally
            {
                try { tblKP.DefaultView.RowFilter = ""; }
                catch { }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Импорт линий связи и КП
        /// </summary>
        public static DialogResult Import(DataTable tblCommLine, DataTable tblKP, Log errLog, out FrmImport frmImport)
        {
            frmImport = null;

            try
            {
                if (tblCommLine.DefaultView.Count == 0)
                {
                    ScadaUtils.ShowInfo(AppPhrases.NoImportData);
                    return(DialogResult.Cancel);
                }
                else
                {
                    // заполнение дерева импортируемых данных: линий связи и КП
                    frmImport = new FrmImport();
                    TreeView treeView = frmImport.TreeView;

                    try
                    {
                        treeView.BeginUpdate();
                        treeView.Nodes.Clear();

                        tblCommLine.DefaultView.Sort = "CommLineNum";
                        tblKP.DefaultView.Sort       = "CommLineNum, KPNum";
                        int kpCnt = tblKP.DefaultView.Count;
                        int kpInd = 0;

                        foreach (DataRowView rowLine in tblCommLine.DefaultView)
                        {
                            int      lineNum  = (int)rowLine["CommLineNum"];
                            TreeNode nodeLine = new TreeNode(Settings.CommLine.GetCaption(lineNum, rowLine["Name"]));
                            nodeLine.Tag = rowLine;
                            treeView.Nodes.Add(nodeLine);

                            DataRowView rowKP     = kpInd < kpCnt ? tblKP.DefaultView[kpInd] : null;
                            int         kpLineNum = rowKP == null ? -1 : (int)rowKP["CommLineNum"];

                            while (0 <= kpLineNum && kpLineNum <= lineNum)
                            {
                                if (kpLineNum == lineNum)
                                {
                                    TreeNode nodeKP =
                                        new TreeNode(Settings.KP.GetCaption((int)rowKP["KPNum"], rowKP["Name"]));
                                    nodeKP.Tag = rowKP;
                                    nodeLine.Nodes.Add(nodeKP);
                                }

                                kpInd++;
                                rowKP     = kpInd < kpCnt ? tblKP.DefaultView[kpInd] : null;
                                kpLineNum = rowKP == null ? -1 : (int)rowKP["CommLineNum"];
                            }
                        }
                    }
                    finally
                    {
                        treeView.EndUpdate();
                    }

                    // отображение формы импорта
                    return(frmImport.ShowDialog());
                }
            }
            catch (Exception ex)
            {
                string errMsg = AppPhrases.PrepareImportFormError1 + ":\r\n" + ex.Message;
                errLog.WriteAction(errMsg);
                ScadaUtils.ShowError(errMsg);

                return(DialogResult.Abort);
            }
        }