/// <summary> /// 用户从DataGridView控件中删除行时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DGV_SDKX_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { if (isLTTID) { var kx = e.Row.Cells[1].Value; var id = e.Row.Cells[2].Value; if (id != null && !string.IsNullOrEmpty(id.ToString())) { var g3e_id = id.ToString(); var isDel = DeleteDBEntity.DeleteSDKX(long.Parse(g3e_id)); PublicMethod.Instance.ShowMessage(isDel ? "删除成功!" : "删除失败!" + string.Format("\t馈线名称:{0}", kx)); if (isDel) { RemoveSdkxList(kx.ToString()); EventTriggerFunc(); } } } else { PublicMethod.Instance.ShowMessage("该设备未锁定,不能编辑!"); e.Cancel = true; } }
/// <summary> /// 更新受电馈线 /// </summary> /// <param name="bdz"></param> /// <param name="kxmc"></param> private void UpdateSDKX(string bdz, string kxmc) { if (_sdkxAcUnion != null && _sdkxAcUnion.Any()) { var oldbdz = comboBox_sc_bdz.Text; var oldkx = comboBox_sc_kxmc.Text; if (string.IsNullOrEmpty(oldbdz) && string.IsNullOrEmpty(oldkx)) { return; } IList <long> errors = new List <long>(); foreach (var sdkx in _sdkxAcUnion) { if (sdkx.GDBDZ.Equals(oldbdz) && sdkx.KXH.Equals(oldkx)) { var isUpdate = UpdateDBEntity.UpdateSDKX_AC(bdz, kxmc, sdkx); if (!isUpdate) { errors.Add(sdkx.G3E_FID); } else { var duplicated = DBEntityFinder.Instance.DuplicatedSdkx(sdkx.G3E_FID, bdz, kxmc); //判断同一个设备是否有重复的受电馈线 if (duplicated) { DeleteDBEntity.DeleteSDKX(sdkx.G3E_ID); } } } } if (errors.Any()) { GetError("更新失败!", errors); } else { MessageBox.Show("更新成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } //重新绑定 GetSymbolSDKXUnion(); } }
private void DelSDKX() { if (_sdkxAcUnion != null && _sdkxAcUnion.Any()) { var oldbdz = comboBox_sc_bdz.Text; var oldkx = comboBox_sc_kxmc.Text; if (string.IsNullOrEmpty(oldbdz) && string.IsNullOrEmpty(oldkx)) { MessageBox.Show("变电站或馈线不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Question); return; } if (MessageBox.Show("确定要删除吗?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { IList <long> errors = new List <long>(); //删除受电馈线 foreach (var sdkx in _sdkxAcUnion.Where(sdkx => sdkx.GDBDZ.Equals(oldbdz) && sdkx.KXH.Equals(oldkx)) ) { var isDel = DeleteDBEntity.DeleteSDKX(sdkx); if (!isDel) { errors.Add(sdkx.G3E_FID); } } if (errors.Any()) { GetError("删除失败!", errors); } else { MessageBox.Show("删除成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } //重新绑定 GetSymbolSDKXUnion(); } } }