public bool Cmp(cmsMap Map) { if ( Map.PointX == this.PointX && Map.PointY == this.PointY && Map.MapInfo == this.MapInfo ) { return(true); } return(false); }
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(); }