/// <summary> /// ɾ��������� /// </summary> public void DeleteObject(string lb) { //��ȡ������� PowerEachList obj = FocusedObject; if (obj == null) { bl = false; return; } int coun = 0; switch (lb) { case "xuqiu": PowerTypes pt = new PowerTypes(); pt.Flag2 = obj.UID; IList<PowerTypes> li = Services.BaseService.GetList<PowerTypes>("SelectPowerTypesByFlag2", pt); coun = li.Count; break; case "xihua": PowerProjectTypes pt1 = new PowerProjectTypes(); pt1.Flag2 = obj.UID; IList<PowerProjectTypes> li1 = Services.BaseService.GetList<PowerProjectTypes>("SelectPowerProjectTypesByFlag2", pt1); coun = li1.Count; break; case "shebei": PowerStuffTypes pt2 = new PowerStuffTypes(); pt2.Flag2 = obj.UID; IList<PowerStuffTypes> li2 = Services.BaseService.GetList<PowerStuffTypes>("SelectPowerStuffTypesByFlag2", pt2); coun = li2.Count; break; case "fanwei": PowersTypes pt3 = new PowersTypes(); pt3.Flag2 = obj.UID; IList<PowersTypes> li3 = Services.BaseService.GetList<PowersTypes>("SelectPowersTypesByFlag2", pt3); coun = li3.Count; break; case "sb": PowerProTypes pt4 = new PowerProTypes(); pt4.Flag2 = obj.UID; IList<PowerProTypes> li4 = Services.BaseService.GetList<PowerProTypes>("SelectPowerProTypesByFlag2INParent", pt4); coun = li4.Count; break; case "gusuan": PSP_PowerProValues_LangFang pt5 = new PSP_PowerProValues_LangFang(); pt5.Flag2 = obj.UID; IList<PSP_PowerProValues_LangFang> li5 = Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2INParent", pt5); coun = li5.Count; break; } if (coun > 0) { MsgBox.Show("�÷��������м�¼����ɾ��"); bl = false; return; } //����ȷ�� if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { bl = false; return; } //ִ��ɾ������ try { Services.BaseService.Delete<PowerEachList>(obj); if (lb == "sb") { Services.BaseService.Update("DeletePowerPicSelect1", obj.UID); Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.UID); } if (lb == "gusuan") { Services.BaseService.Update("DeletePowerPicSelect1", obj.UID); Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.UID); } } catch { //Debug.Fail(exc.Message); //HandleException.TryCatch(exc); return; } this.gridView.BeginUpdate(); //��ס��ǰ���������� int iOldHandle = this.gridView.FocusedRowHandle; //��������ɾ�� ObjectList.Remove(obj); //ˢ�±�� gridControl.RefreshDataSource(); //�����µĽ��������� GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle); this.gridView.EndUpdate(); }
private void simpleButton1_Click(object sender, EventArgs e) { type = psp_Year.Year = spinEdit1.Text; if (type.ToString() == "") { MsgBox.Show("类别名称不能为空"); return; } try { if (!IsUpdate) { if (Common.Services.BaseService.GetObject("SelectPowerStuffYearsByYearFlag", psp_Year) == null) { try { Common.Services.BaseService.Create<PowerStuffYears>(psp_Year); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MsgBox.Show("出错啦:" + ex.Message); } } else { MsgBox.Show("此分类已经存在,请重新输入!"); } } else { try { PowerStuffTypes psp_Type = new PowerStuffTypes(); psp_Type.Flag2 = type1; IList<PowerStuffTypes> listTypes = new List<PowerStuffTypes>(); try { listTypes = Common.Services.BaseService.GetList<PowerStuffTypes>("SelectPowerStuffTypesByFlag2", psp_Type); } catch (Exception ex) { MsgBox.Show(ex.Message); } foreach (PowerStuffTypes pstt in listTypes) { PowerStuffValues psv = new PowerStuffValues(); psv.ID = pstt.ID; psv.Year = psp_Year.Year; psv.Value = year2; Common.Services.BaseService.Update("UpdatePowerStuffValuesByYear", psv); } Common.Services.BaseService.Update<PowerStuffYears>(psp_Year); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MsgBox.Show("出错啦:" + ex.Message); } } } catch(Exception ex) { MsgBox.Show("出错啦:" + ex.Message); } }