/// <summary> /// 修改从属 /// </summary> /// <param name="oldName"></param> /// <param name="newName"></param> private void ModifyDependence(string oldName, string newName) { if (oldName.Equals(newName)) { return; } //获取自身公共属性 var common = DBEntityFinder.Instance.GetCommonByG3e_FID(g3eObject.G3E_FID); if (common == null) { return; } //新名称 common.SBMC = newName; //更新自身公共属性 var result = UpdateDBEntity.UpdateCommon(common); if (result) { //更新电房标注 UpdateDBText(g3eObject.G3E_FID, newName, oldName); //获取从属 var coms = DBEntityFinder.Instance.GetCommonsByG3e_ID(common.G3E_ID); if (coms.Any()) { //更新从属 foreach (var com in coms) { if (string.IsNullOrEmpty(com.SBMC)) { continue; } var oldTextString = com.SBMC; if (!string.IsNullOrEmpty(oldName) && com.SBMC.Contains(oldName)) { var newSBMC = com.SBMC.Replace(oldName, newName); com.SBMC = newSBMC; var bl = UpdateDBEntity.UpdateCommon(com); if (bl) { //更新从属设备的标注 UpdateDBText(com.G3E_FID, newSBMC, oldTextString); } } } } else { PublicMethod.Instance.AlertDialog("无从属关系!"); } textBox_DF_OLDNAME.Text = newName; } }
/// <summary> /// 修改级联设备 /// </summary> /// <param name="oldName"></param> /// <param name="newName"></param> private void ModifyDependence(string oldName, string newName) { if (string.IsNullOrEmpty(newName)) { return; } if (oldName.Equals(newName)) { PublicMethod.Instance.AlertDialog("修改前后名称一样,修改失败!\n"); return; } // 更新台架的功能位置 if (tj_gnwz == null) { return; } tj_gnwz.MC = newName; var result = UpdateDBEntity.UpdateGNWZ(tj_gnwz); if (!result) { LogManager.Instance.Error("更新台架功能位置属性出错!\n"); } //更新台架自身公共属性 if (tj_comm == null) { return; } tj_comm.SBMC = newName; //新名称 tj_comm.CD_SSDW = cb_ssdw.Text; // 所属单位 tj_comm.CD_SSBDZ = cb_ssbdz.Text; // 所属变电站 tj_comm.CD_SSXL = cb_ssxl.Text; // 所属线路 tj_comm.CD_DYDJ = cb_dydj.Text; // 电压等级 tj_comm.CD_SMZQ = cb_smzq.Text; // 生命周期 //tj_comm.GNWZ_SSGDS = cb_ssgds.Text; // 所属供电所 result = UpdateDBEntity.UpdateCommon(tj_comm); if (!result) { return; } //更新台架标注 UpdateDBText(g3eObject.G3E_FID, newName, oldName); //更新级联设备公共属性 if (tj_devs_comm.Any()) { foreach (var com in tj_devs_comm) { if (string.IsNullOrEmpty(com.SBMC)) { continue; } var oldTextString = com.SBMC; if (string.IsNullOrEmpty(oldName) || !com.SBMC.Contains(oldName)) { continue; } var newSBMC = com.SBMC.Replace(oldName, newName); com.SBMC = newSBMC; if (com.G3E_FNO == 148) { com.CD_SSDW = cb_ssdw.Text; // 所属单位 com.CD_SSBDZ = cb_ssbdz.Text; // 所属变电站 com.CD_SSXL = cb_ssxl.Text; // 所属线路 if (!String.IsNullOrEmpty(cb_dydj.Text)) { com.CD_DYDJ = cb_dydj.Text; // 电压等级 } com.CD_SMZQ = cb_smzq.Text; // 生命周期 //com.GNWZ_SSGDS = cb_ssgds.Text; // 所属供电所 } var bl = UpdateDBEntity.UpdateCommon(com); if (bl) { //更新从属设备的标注 UpdateDBText(com.G3E_FID, newSBMC, oldTextString); } } //更新级联设备功能位置属性 foreach (var gnwz in tj_devs_gnwz) { if (string.IsNullOrEmpty(gnwz.MC)) { continue; } if (string.IsNullOrEmpty(oldName) || !gnwz.MC.Contains(oldName)) { continue; } var newSBMC = gnwz.MC.Replace(oldName, newName); gnwz.MC = newSBMC; UpdateDBEntity.UpdateGNWZ(gnwz); } PublicMethod.Instance.ShowMessage("修改成功!\n"); } else { PublicMethod.Instance.AlertDialog("台架无级联设备!"); } //textBox_DF_OLDNAME.Text = newName; }