Esempio n. 1
0
        private void InitNodesTree()
        {
            NodeTreeCtr.GetStateImage += TreeList_GetStateImage;
            NodesInfo nodes = new NodesInfo("NodesInfo.xml");

            data         = nodes.Nodes;
            selectedData = data[0];
            TreeListColumn column = NodeTreeCtr.Columns.Add();

            column.Caption   = "电表位置";
            column.FieldName = "Name";
            column.Visible   = true;
            TreeListColumn columnHasChildren = NodeTreeCtr.Columns.Add();

            columnHasChildren.Caption   = "是否叶子节点";
            columnHasChildren.FieldName = "HasChildren";
            columnHasChildren.Visible   = false;
            TreeListColumn columnID = NodeTreeCtr.Columns.Add();

            columnID.Caption            = "MID";
            columnID.FieldName          = "MID";
            columnID.Visible            = false;
            NodeTreeCtr.DataSource      = nodes.Nodes;
            NodeTreeCtr.ParentFieldName = "ParentID";
            NodeTreeCtr.KeyFieldName    = "MID";
            NodeTreeCtr.ExpandAll();
            NodeTreeCtr.FocusedNode = NodeTreeCtr.Nodes[0];
        }
Esempio n. 2
0
        private void NodeTreeCtr_Click(object sender, EventArgs e)
        {
            int MID        = int.Parse(NodeTreeCtr.FocusedNode.GetValue("MID").ToString());
            var selectData =
                data.Where(d => d.MID == MID).ToList();

            if (selectData == null)
            {
                return;
            }
            selectedData = selectData[0];
            ChangeTextBoxs(selectedData);
            if (selectedData.HasChildren)
            {
                foreach (TextBox tb in tBoxs)
                {
                    tb.ReadOnly = true;
                }
            }
            else
            {
                foreach (TextBox tb in tBoxs)
                {
                    tb.ReadOnly = false;
                }
            }
        }
Esempio n. 3
0
        public ElectricityOriginalData Calculate(TreeListNode node, bool increase_or_not)
        {
            if (!node.HasChildren)
            {
                var result = data.Where(d => d.MID.ToString() == node.GetValue("MID").ToString()).ToList();
                ElectricityOriginalData childData = result[0] as ElectricityOriginalData;

                if (increase_or_not)
                {
                    childData.WPP += childData.WPPIncre;
                    childData.WPN += childData.WPNIncre;
                    childData.WQP += childData.WQPIncre;
                    childData.WQN += childData.WQNIncre;
                }
                return(childData);
            }
            else
            {
                var result = data.Where(d => d.MID.ToString() == node.GetValue("MID").ToString()).ToList();
                ElectricityOriginalData childData = result[0] as ElectricityOriginalData;
                childData.ClearData();
                foreach (TreeListNode treeListNode in node.Nodes)
                {
                    ElectricityOriginalData temp = Calculate(treeListNode, increase_or_not);
                    childData.WPP += temp.WPP;
                    childData.WPN += temp.WPN;
                    childData.WQP += temp.WQP;
                    childData.WQN += temp.WQN;
                    childData.IA  += temp.IA;
                    childData.IB  += temp.IB;
                    childData.IC  += temp.IC;
                    childData.PA  += temp.PA;
                    childData.PB  += temp.PB;
                    childData.PC  += temp.PC;
                    childData.PS  += temp.PS;
                    childData.QA  += temp.QA;
                    childData.QB  += temp.QB;
                    childData.QC  += temp.QC;
                    childData.QS  += temp.QS;
                    childData.SA  += temp.SA;
                    childData.SB  += temp.SB;
                    childData.SC  += temp.SC;
                    childData.SS  += temp.SS;
                }
                return(childData);
            }
        }
Esempio n. 4
0
        private ElectricityOriginalData GetNodesInfo(XmlNode node, int ParentID)
        {
            if (node.ChildNodes.Count == 0)
            {
                ElectricityOriginalData leafData = new ElectricityOriginalData(node, ParentID);
                leafData.HasChildren = false;
                return(leafData);
            }

            ElectricityOriginalData data = new ElectricityOriginalData(node, ParentID);

            data.HasChildren = true;
            foreach (XmlNode childNode in node.ChildNodes)
            {
                Nodes.Add(GetNodesInfo(childNode, data.MID));
            }
            return(data);
        }
Esempio n. 5
0
 private void ChangeTextBoxs(ElectricityOriginalData data)
 {
     if (data == null)
     {
         return;
     }
     textBoxName.Text     = data.Name;
     textBoxPID.Text      = data.PID.ToString();
     textBoxMID.Text      = data.MID.ToString();
     textBoxUA.Text       = data.UA.ToString();
     textBoxUB.Text       = data.UB.ToString();
     textBoxUC.Text       = data.UC.ToString();
     textBoxUAB.Text      = data.UAB.ToString();
     textBoxUBC.Text      = data.UBC.ToString();
     textBoxUCA.Text      = data.UCA.ToString();
     textBoxIA.Text       = data.IA.ToString();
     textBoxIB.Text       = data.IB.ToString();
     textBoxIC.Text       = data.IC.ToString();
     textBoxPA.Text       = data.PA.ToString();
     textBoxPB.Text       = data.PB.ToString();
     textBoxPC.Text       = data.PC.ToString();
     textBoxPS.Text       = data.PS.ToString();
     textBoxQA.Text       = data.QA.ToString();
     textBoxQB.Text       = data.QB.ToString();
     textBoxQC.Text       = data.QC.ToString();
     textBoxQS.Text       = data.QS.ToString();
     textBoxSA.Text       = data.SA.ToString();
     textBoxSB.Text       = data.SB.ToString();
     textBoxSC.Text       = data.SC.ToString();
     textBoxSS.Text       = data.SS.ToString();
     textBoxPFA.Text      = data.PFA.ToString();
     textBoxPFB.Text      = data.PFB.ToString();
     textBoxPFC.Text      = data.PFC.ToString();
     textBoxPFS.Text      = data.PFS.ToString();
     textBoxFR.Text       = data.FR.ToString();
     textBoxWPP.Text      = data.WPP.ToString();
     textBoxWPN.Text      = data.WPN.ToString();
     textBoxWQN.Text      = data.WQN.ToString();
     textBoxWQP.Text      = data.WQP.ToString();
     textBoxIStatus.Text  = data.IStatus;
     StringFormatCtr.Text = "通信内容: " + TaskSendMessageAsyn.FormatMessage(data);
 }
Esempio n. 6
0
        public static string FormatMessage(ElectricityOriginalData data)
        {
            string message = "";

            message += "[,T,1,";
            message += data.PID + ",";
            message += data.MID + ",";
            message += data.UA.ToString("0.00") + ",";
            message += data.UB.ToString("0.00") + ",";
            message += data.UC.ToString("0.00") + ",";
            message += data.UAB.ToString("0.00") + ",";
            message += data.UBC.ToString("0.00") + ",";
            message += data.UCA.ToString("0.00") + ",";
            message += data.IA.ToString("0.00") + ",";
            message += data.IB.ToString("0.00") + ",";
            message += data.IC.ToString("0.00") + ",";
            message += data.PA.ToString("0.00") + ",";
            message += data.PB.ToString("0.00") + ",";
            message += data.PC.ToString("0.00") + ",";
            message += data.PS.ToString("0.00") + ",";
            message += data.QA.ToString("0.00") + ",";
            message += data.QB.ToString("0.00") + ",";
            message += data.QC.ToString("0.00") + ",";
            message += data.QS.ToString("0.00") + ",";
            message += data.SA.ToString("0.00") + ",";
            message += data.SB.ToString("0.00") + ",";
            message += data.SC.ToString("0.00") + ",";
            message += data.SS.ToString("0.00") + ",";
            message += data.PFA + ",";
            message += data.PFB + ",";
            message += data.PFC + ",";
            message += data.PFS + ",";
            message += data.FR + ",";
            message += data.WPP.ToString("0.00") + ",";
            message += data.WPN.ToString("0.00") + ",";
            message += data.WQP.ToString("0.00") + ",";
            message += data.WQN.ToString("0.00") + ",";
            message += data.IStatus + ",";

            message += "]";
            return(message);
        }
Esempio n. 7
0
        public void RecordNodesInfo(ElectricityOriginalData data)
        {
            XmlNodeList xlist = xmlFile.SelectNodes("//Node");

            foreach (XmlNode xn in xlist)
            {
                if (xn.Attributes["MID"].Value == data.MID.ToString())
                {
                    xn.Attributes["UA"].InnerText  = data.UA.ToString();
                    xn.Attributes["UB"].InnerText  = data.UB.ToString();
                    xn.Attributes["UC"].InnerText  = data.UC.ToString();
                    xn.Attributes["UAB"].InnerText = data.UAB.ToString();
                    xn.Attributes["UBC"].InnerText = data.UBC.ToString();
                    xn.Attributes["UCA"].InnerText = data.UCA.ToString();
                    xn.Attributes["IA"].InnerText  = data.IA.ToString();
                    xn.Attributes["IB"].InnerText  = data.IB.ToString();
                    xn.Attributes["IC"].InnerText  = data.IC.ToString();
                    xn.Attributes["PA"].InnerText  = data.PA.ToString();
                    xn.Attributes["PB"].InnerText  = data.PB.ToString();
                    xn.Attributes["PC"].InnerText  = data.PC.ToString();
                    xn.Attributes["PS"].InnerText  = data.PS.ToString();
                    xn.Attributes["QA"].InnerText  = data.QA.ToString();
                    xn.Attributes["QB"].InnerText  = data.QB.ToString();
                    xn.Attributes["QC"].InnerText  = data.QC.ToString();
                    xn.Attributes["QS"].InnerText  = data.QS.ToString();
                    xn.Attributes["SA"].InnerText  = data.SA.ToString();
                    xn.Attributes["SB"].InnerText  = data.SB.ToString();
                    xn.Attributes["SC"].InnerText  = data.SC.ToString();
                    xn.Attributes["SS"].InnerText  = data.SS.ToString();
                    xn.Attributes["PFA"].InnerText = data.PFA.ToString();
                    xn.Attributes["PFB"].InnerText = data.PFB.ToString();
                    xn.Attributes["PFC"].InnerText = data.PFC.ToString();
                    xn.Attributes["PFS"].InnerText = data.PFS.ToString();
                    xn.Attributes["FR"].InnerText  = data.FR.ToString();
                    xn.Attributes["WPP"].InnerText = data.WPP.ToString();
                    xn.Attributes["WPN"].InnerText = data.WPN.ToString();
                    xn.Attributes["WQP"].InnerText = data.WQP.ToString();
                    xn.Attributes["WQN"].InnerText = data.WQN.ToString();
                }
            }
        }
Esempio n. 8
0
        public static string FormatMessage(ElectricityOriginalData data)
        {
            string message = "";
            message += "[,T,1,";
            message += data.PID + ",";
            message += data.MID + ",";
            message += data.UA.ToString("0.00") + ",";
            message += data.UB.ToString("0.00") + ",";
            message += data.UC.ToString("0.00") + ",";
            message += data.UAB.ToString("0.00") + ",";
            message += data.UBC.ToString("0.00") + ",";
            message += data.UCA.ToString("0.00") + ",";
            message += data.IA.ToString("0.00") + ",";
            message += data.IB.ToString("0.00") + ",";
            message += data.IC.ToString("0.00") + ",";
            message += data.PA.ToString("0.00") + ",";
            message += data.PB.ToString("0.00") + ",";
            message += data.PC.ToString("0.00") + ",";
            message += data.PS.ToString("0.00") + ",";
            message += data.QA.ToString("0.00") + ",";
            message += data.QB.ToString("0.00") + ",";
            message += data.QC.ToString("0.00") + ",";
            message += data.QS.ToString("0.00") + ",";
            message += data.SA.ToString("0.00") + ",";
            message += data.SB.ToString("0.00") + ",";
            message += data.SC.ToString("0.00") + ",";
            message += data.SS.ToString("0.00") + ",";
            message += data.PFA + ",";
            message += data.PFB + ",";
            message += data.PFC + ",";
            message += data.PFS + ",";
            message += data.FR + ",";
            message += data.WPP.ToString("0.00") + ",";
            message += data.WPN.ToString("0.00") + ",";
            message += data.WQP.ToString("0.00") + ",";
            message += data.WQN.ToString("0.00") + ",";
            message += data.IStatus + ",";

            message += "]";
            return message;
        }
Esempio n. 9
0
 private void NodeTreeCtr_Click(object sender, EventArgs e)
 {
     int MID = int.Parse(NodeTreeCtr.FocusedNode.GetValue("MID").ToString());
     var selectData =
         data.Where(d => d.MID == MID).ToList();
     if (selectData == null) return;
     selectedData = selectData[0];
     ChangeTextBoxs(selectedData);
     if (selectedData.HasChildren)
     {
         foreach (TextBox tb in tBoxs)
         {
             tb.ReadOnly = true;
         }
     }
     else
         foreach (TextBox tb in tBoxs)
         {
             tb.ReadOnly = false;
         }
 }
Esempio n. 10
0
 private void InitNodesTree()
 {
     NodeTreeCtr.GetStateImage += TreeList_GetStateImage;
     NodesInfo nodes = new NodesInfo("NodesInfo.xml");
     data = nodes.Nodes;
     selectedData = data[0];
     TreeListColumn column = NodeTreeCtr.Columns.Add();
     column.Caption = "电表位置";
     column.FieldName = "Name";
     column.Visible = true;
     TreeListColumn columnHasChildren = NodeTreeCtr.Columns.Add();
     columnHasChildren.Caption = "是否叶子节点";
     columnHasChildren.FieldName = "HasChildren";
     columnHasChildren.Visible = false;
     TreeListColumn columnID = NodeTreeCtr.Columns.Add();
     columnID.Caption = "MID";
     columnID.FieldName = "MID";
     columnID.Visible = false;
     NodeTreeCtr.DataSource = nodes.Nodes;
     NodeTreeCtr.ParentFieldName = "ParentID";
     NodeTreeCtr.KeyFieldName = "MID";
     NodeTreeCtr.ExpandAll();
     NodeTreeCtr.FocusedNode = NodeTreeCtr.Nodes[0];
 }
Esempio n. 11
0
 private void ChangeTextBoxs(ElectricityOriginalData data)
 {
     if (data == null) return;
     textBoxName.Text = data.Name;
     textBoxPID.Text = data.PID.ToString();
     textBoxMID.Text = data.MID.ToString();
     textBoxUA.Text = data.UA.ToString();
     textBoxUB.Text = data.UB.ToString();
     textBoxUC.Text = data.UC.ToString();
     textBoxUAB.Text = data.UAB.ToString();
     textBoxUBC.Text = data.UBC.ToString();
     textBoxUCA.Text = data.UCA.ToString();
     textBoxIA.Text = data.IA.ToString();
     textBoxIB.Text = data.IB.ToString();
     textBoxIC.Text = data.IC.ToString();
     textBoxPA.Text = data.PA.ToString();
     textBoxPB.Text = data.PB.ToString();
     textBoxPC.Text = data.PC.ToString();
     textBoxPS.Text = data.PS.ToString();
     textBoxQA.Text = data.QA.ToString();
     textBoxQB.Text = data.QB.ToString();
     textBoxQC.Text = data.QC.ToString();
     textBoxQS.Text = data.QS.ToString();
     textBoxSA.Text = data.SA.ToString();
     textBoxSB.Text = data.SB.ToString();
     textBoxSC.Text = data.SC.ToString();
     textBoxSS.Text = data.SS.ToString();
     textBoxPFA.Text = data.PFA.ToString();
     textBoxPFB.Text = data.PFB.ToString();
     textBoxPFC.Text = data.PFC.ToString();
     textBoxPFS.Text = data.PFS.ToString();
     textBoxFR.Text = data.FR.ToString();
     textBoxWPP.Text = data.WPP.ToString();
     textBoxWPN.Text = data.WPN.ToString();
     textBoxWQN.Text = data.WQN.ToString();
     textBoxWQP.Text = data.WQP.ToString();
     textBoxIStatus.Text = data.IStatus;
     StringFormatCtr.Text = "通信内容: " + TaskSendMessageAsyn.FormatMessage(data);
 }