Пример #1
0
        private void NodeNameOK()
        {
            bool   flag = true;
            string sql  = "select Descripe from tb_AreaSet";

            sql += " where IPandPort = '" + tboxoldtext.Split(',')[0] + "'";
            sql += " and AreaNum = '" + tboxoldtext.Split(',')[1] + "'";
            for (int i = 0; i < FormMain.DataModel.AreaSet.Count; i++)
            {
                if (FormMain.DataModel.AreaSet[i].IPport == tboxoldtext.Split(',')[0] &&
                    FormMain.DataModel.AreaSet[i].AreaNum == tboxoldtext.Split(',')[1]
                    )
                {
                    string s = FormMain.DataModel.AreaSet[i].Describe;
                    if (s == tBox_new.Text)
                    {
                        flag = false;
                    }
                }
            }
            if (flag)
            {
                sql  = "select Map from tb_AreaSet";
                sql += " where IPandPort = '" + tboxoldtext.Split(',')[0] + "'";
                sql += " and AreaNum = '" + tboxoldtext.Split(',')[1] + "'";
                sql += " and Descripe = '" + tboxoldtext.Split(',')[2] + "'";
                string mapTemp = "";
                for (int i = 0; i < FormMain.DataModel.AreaSet.Count; i++)
                {
                    if (FormMain.DataModel.AreaSet[i].IPport == tboxoldtext.Split(',')[0] &&
                        FormMain.DataModel.AreaSet[i].AreaNum == tboxoldtext.Split(',')[1] &&
                        FormMain.DataModel.AreaSet[i].Describe == tboxoldtext.Split(',')[2]
                        )
                    {
                        mapTemp = FormMain.DataModel.AreaSet[i].Map;
                    }
                }



                string descripe = tBox_new.Text.Trim();
                sql  = " update tb_AreaSet set Descripe ='" + descripe;
                sql += "' Where Descripe = '" + tboxoldtext.Split(',')[2] + "'";
                sql += " and IPandPort = '" + tboxoldtext.Split(',')[0] + "'";
                sql += " and AreaNum = '" + tboxoldtext.Split(',')[1] + "'";
                for (int i = 0; i < FormMain.DataModel.AreaSet.Count; i++)
                {
                    cmsAreaSet updAS = FormMain.DataModel.AreaSet[i];
                    if (updAS.IPport == tboxoldtext.Split(',')[0] &&
                        updAS.AreaNum == tboxoldtext.Split(',')[1] &&
                        updAS.Describe == tboxoldtext.Split(',')[2]
                        )
                    {
                        updAS.Describe = descripe;
                        FormMain.DataModel.AreaSet[i] = updAS;
                    }
                }

                sql = " update tb_Map set MapInfo ='" +
                      FormMain.CurrentNode.Split(',')[0] + "," +
                      FormMain.CurrentNode.Split(',')[1] + "," +
                      tBox_new.Text +
                      " 'Where MapInfo = '" + FormMain.CurrentNode + "'";
                for (int i = 0; i < FormMain.DataModel.Map.Count; i++)
                {
                    cmsMap updM = FormMain.DataModel.Map[i];
                    if (updM.MapInfo == FormMain.CurrentNode)
                    {
                        updM.MapInfo = FormMain.CurrentNode.Split(',')[0] + "," + FormMain.CurrentNode.Split(',')[1] + "," + tBox_new.Text;
                        FormMain.DataModel.Map[i] = updM;
                    }
                }

                FormMain.ContentBuff[mapTemp] = descripe;

                thisMapNodeName(tBox_new.Text);

                LoadTreeView();
                tBox_old.Text = tBox_new.Text;
                tBox_new.Text = "";
            }
            else
            {
                MessageBox.Show("name repeate", "WARN");
            }
        }
        private void btn_confirm_Click(object sender, EventArgs e)
        {
            string addressOld = textBox_IP.Text.Trim();
            string address    = textBox_IPn.Text.Trim();
            string position   = textBox_SatNamen.Text.Trim();
            string type       = textBox_Portn.Text.Trim();

            string sql = null;

            try
            {
                sql  = " update tb_AreaSet set ";
                sql += "    AreaNum = '" + address;
                sql += "' , Descripe = '" + position;
                sql += "' , DeviceType = '" + type;
                sql += "' , Map = replace( Map , '," + addressOld + "-' , '," + address + "-' )";
                sql += " Where IPandPort = '" + ipPort + "' and AreaNum = '" + addr + "' and Descripe = '" + posi + "'";
                for (int i = 0; i < FormMain.DataModel.AreaSet.Count; i++)
                {
                    cmsAreaSet tmpAS = FormMain.DataModel.AreaSet[i];
                    if (tmpAS.IPport == ipPort &&
                        tmpAS.AreaNum == addr &&
                        tmpAS.Describe == posi
                        )
                    {
                        tmpAS.AreaNum    = address;
                        tmpAS.Describe   = position;
                        tmpAS.DeviceType = type;
                        tmpAS.Map        = tmpAS.Map.Replace(addressOld + "-", address + "-");
                        FormMain.DataModel.AreaSet[i] = tmpAS;
                    }
                }

                sql  = " update tb_AreaSet set ";
                sql += "    AreaNum = '" + address;
                sql += "' , DeviceType = '" + type;
                sql += "' , Map = replace( Map , '," + addressOld + "-' , '," + address + "-' )";
                sql += " Where IPandPort = '" + ipPort + "' and AreaNum = '" + addr + "'";
                for (int i = 0; i < FormMain.DataModel.AreaSet.Count; i++)
                {
                    cmsAreaSet tmpAS = FormMain.DataModel.AreaSet[i];
                    if (tmpAS.IPport == ipPort &&
                        tmpAS.AreaNum == addr
                        )
                    {
                        tmpAS.AreaNum    = address;
                        tmpAS.DeviceType = type;
                        tmpAS.Map        = tmpAS.Map.Replace(addressOld + "-", address + "-");
                        FormMain.DataModel.AreaSet[i] = tmpAS;
                    }
                }

                update_datagridView();
            }

            catch
            {
                MessageBox.Show("Zone change failed");
            }



            try
            {
                sql  = " update tb_Map set ";
                sql += " MapInfo = '" + ipPort + "," + address + "," + position + "'";
                sql += " Where MapInfo = '" + ipPort + "," + addr + "," + posi + "'";
                for (int i = 0; i < FormMain.DataModel.Map.Count; i++)
                {
                    cmsMap tmpMap = FormMain.DataModel.Map[i];
                    if (tmpMap.MapInfo == ipPort + "," + addr + "," + posi)
                    {
                        tmpMap.MapInfo            = ipPort + "," + address + "," + position;
                        FormMain.DataModel.Map[i] = tmpMap;
                    }
                }

                sql  = " update tb_Map set ";
                sql += " MapInfo = replace(MapInfo,'," + addr + ",','," + address + ",'" + ")";
                for (int i = 0; i < FormMain.DataModel.Map.Count; i++)
                {
                    cmsMap tmpMap = FormMain.DataModel.Map[i];
                    tmpMap.MapInfo            = tmpMap.MapInfo.Replace(addr, address);
                    FormMain.DataModel.Map[i] = tmpMap;
                }
            }

            catch
            {
                MessageBox.Show("map change failed");
            }


            GetDatabaseData();
            LoadTreeView();
            this.Close();
        }
Пример #3
0
        private void btn_Done_Click(object sender, EventArgs e)
        {
            if (textBox_AreaNum.Text != "" && textBox_Position.Text != "")
            {
                try
                {
                    data[0] = StaBuff[comboBox_StaName.Text].Trim();
                }
                catch
                {
                    data[0] = "null";
                }
                data[1] = textBox_AreaNum.Text.Trim();
                data[2] = comboBox_AreaStatus.Text.Trim();
                data[3] = textBox_Position.Text.Trim();
                data[4] = comboBox_type.Text.Split('-')[1].Trim();
                bool flag = true;

                string        sql     = "select AreaNum from tb_AreaSet Where IPandPort ='" + data[0] + "'";
                List <string> areaNum = new List <string>();
                foreach (cmsAreaSet cmsAS in FormMain.DataModel.AreaSet)
                {
                    if (cmsAS.IPport == data[0])
                    {
                        areaNum.Add(cmsAS.AreaNum);
                    }
                }

                for (int i = 0; i < areaNum.Count; i++)
                {
                    string temp = areaNum[i];
                    if (temp == data[1])
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    char CheckState = (comboBox_type.Text.Split('-')[0] == "SingleZone" ? 'N' : 'Y');

                    if (CheckState == 'N')
                    {
                        string insertstr = "insert into tb_areaset(ipandport,areanum,status,descripe,devicetype,map) values('";
                        for (int i = 0; i < 5; i++)
                        {
                            insertstr += data[i] + "', '";
                        }
                        insertstr += data[0] + "," + data[1] + "-0" + "')";
                        cmsAreaSet addAS = new cmsAreaSet();
                        addAS.IPport     = data[0];
                        addAS.AreaNum    = data[1];
                        addAS.Status     = data[2];
                        addAS.Describe   = data[3];
                        addAS.DeviceType = data[4];
                        addAS.Map        = data[0] + "," + data[1] + "-0";
                        FormMain.DataModel.AreaSet.Add(addAS);

                        FormDenfenAreaSet.DataLength++;
                        UpdateDataBase(insertstr);
                    }
                    else
                    {
                        for (int j = 1; j < 3; j++)
                        {
                            string insertstr = "insert into tb_areaset(ipandport,areanum,status,descripe,devicetype,map) values('";
                            for (int i = 0; i < 3; i++)
                            {
                                insertstr += data[i] + "', '";
                            }
                            insertstr += data[3] + "_" + j.ToString() + "', '";
                            insertstr += data[4] + "', '";
                            insertstr += data[0] + "," + data[1] + "-" + j.ToString() + "')";

                            cmsAreaSet addAS = new cmsAreaSet();
                            addAS.IPport     = data[0];
                            addAS.AreaNum    = data[1];
                            addAS.Status     = data[2];
                            addAS.Describe   = data[3] + "_" + j.ToString();
                            addAS.DeviceType = data[4];
                            addAS.Map        = data[0] + "," + data[1] + "-" + j.ToString();
                            FormMain.DataModel.AreaSet.Add(addAS);

                            FormDenfenAreaSet.DataLength++;
                            UpdateDataBase(insertstr);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Zone Number Is Repeated Under The Same Base Station", "WARN");
                }
            }
            else
            {
                MessageBox.Show("Please complete the filling");
            }
            LoadTreeView();
        }
Пример #4
0
        private void btn_confirm_Click(object sender, EventArgs e)
        {
            string ipn   = textBox_IPn.Text.Trim();
            string namen = textBox_SatNamen.Text.Trim();
            string portn = textBox_Portn.Text.Trim();

            if (true)
            {
                string sql = null;

                try
                {
                    sql  = " update tb_StaSet set";
                    sql += "    IP= '" + ipn;
                    sql += "' , Port= '" + portn;
                    sql += "' , StaName= '" + namen;
                    sql += "' , IPandPort= '" + ipn + ":" + portn;
                    sql += " 'Where IPandPort = '" + ip + ":" + port + "'";
                    for (int i = 0; i < FormMain.DataModel.StationSet.Count; i++)
                    {
                        cmsStationSet udSS = FormMain.DataModel.StationSet[i];
                        if (udSS.IPandPort == (ip + ":" + port))
                        {
                            udSS.IP        = ipn;
                            udSS.Port      = portn;
                            udSS.StaName   = namen;
                            udSS.IPandPort = ipn + ":" + portn;
                            FormMain.DataModel.StationSet[i] = udSS;
                        }
                    }

                    update_datagridView();
                }
                catch
                {
                    MessageBox.Show("change failed");
                }

                try
                {
                    sql  = " update tb_AreaSet set ";
                    sql += " IPandPort= '" + ipn + ":" + portn;
                    sql += "' , Map = replace( Map , '" + ip + ":" + port + "' , '" + ipn + ":" + portn + "' )";
                    sql += " Where IPandPort = '" + ip + ":" + port + "'";
                    for (int i = 0; i < FormMain.DataModel.AreaSet.Count; i++)
                    {
                        cmsAreaSet udAS = FormMain.DataModel.AreaSet[i];
                        if (udAS.IPport == (ip + ":" + port))
                        {
                            udAS.IPport = ipn + ":" + portn;
                            udAS.Map    = udAS.Map.Replace(ip + ":" + port, ipn + ":" + portn);
                            FormMain.DataModel.AreaSet[i] = udAS;
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("change failed");
                }

                try
                {
                    sql  = " update tb_Map set ";
                    sql += " MapInfo = replace( MapInfo , '" + ip + ":" + port + "' , '" + ipn + ":" + portn + "' )";
                    foreach (cmsMap udMap in FormMain.DataModel.Map)
                    {
                        udMap.MapInfo = udMap.MapInfo.Replace(ip + ":" + port, ipn + ":" + portn);
                    }
                }
                catch
                {
                    MessageBox.Show("change failed");
                }


                GetDatabaseData();
                LoadTreeView();
                this.Close();
            }
            else
            {
                MessageBox.Show("Fill in non-standard");
            }
        }