protected bool SaveRecord() { //����/�� ���� try { if (IsCreate) { Services.BaseService.Create<PSP_VolumeBalance>(_obj); } else { Services.BaseService.Update<PSP_VolumeBalance>(_obj); } } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return false ; } if (_obj.S1 == "1") { PSP_VolumeBalance ob = new PSP_VolumeBalance(); ob.Year = EnsureBaseYear(); ob.TypeID = type; ob.Flag = flag; IList<PSP_VolumeBalance> list0 = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeIDAndYear", ob); if (list0 != null) { if (list0.Count == 1) { list0[0].S1 = "0"; Services.BaseService.Update<PSP_VolumeBalance>(list0[0]); } } PSP_VolumeBalanceDataSource BaseYearrate = new PSP_VolumeBalanceDataSource(); BaseYearrate.UID = baseyeartype; BaseYearrate.Flag = flag; BaseYearrate.Value = _obj.Year; BaseYearrate.TypeID = Convert.ToInt32(_obj.TypeID); Services.BaseService.Update("UpdatePSP_VolumeBalanceDataSource2", BaseYearrate); } else if (_obj.Year == EnsureBaseYear() /*|| (EnsureBaseYear() == baseyear)*/) { PSP_VolumeBalance ob = new PSP_VolumeBalance(); ob.Flag = flag; ob.TypeID = type; IList<PSP_VolumeBalance> list0 = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeID", ob); if (list0 != null) if (list0.Count > 0) ob = list0[0]; PSP_VolumeBalanceDataSource BaseYearrate = new PSP_VolumeBalanceDataSource(); BaseYearrate.Flag = flag; BaseYearrate.UID = baseyeartype; BaseYearrate.Value = baseyear; BaseYearrate.TypeID = Convert.ToInt32(_obj.TypeID); Services.BaseService.Update("UpdatePSP_VolumeBalanceDataSource2", BaseYearrate); PSP_VolumeBalanceDataSource volumtemp = new PSP_VolumeBalanceDataSource(); volumtemp.TypeID = Convert.ToInt32(type); volumtemp.Flag = flag; IList<PSP_VolumeBalanceDataSource> list = Services.BaseService.GetList<PSP_VolumeBalanceDataSource>("SelectPSP_VolumeBalanceDataSourceByTypeID", volumtemp); if (ob != null) if (ob.UID != "") foreach (PSP_VolumeBalanceDataSource psptemp in list) { if (psptemp.UID == baseyeartype) continue; if (hs[psptemp.Name] != null) ob.GetType().GetProperty("L" + hs[psptemp.Name].ToString()).SetValue(ob, psptemp.Value, null); } try { ob.S1 = "1"; Services.BaseService.Update<PSP_VolumeBalance>(ob); isresum = true; } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } } //�����ѳɹ� return true; }
protected bool SaveRecord() { //创建/修改 对象 try { if (IsCreate) { Services.BaseService.Create <PSP_VolumeBalance>(_obj); } else { Services.BaseService.Update <PSP_VolumeBalance>(_obj); } } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } if (_obj.S1 == "1") { PSP_VolumeBalance ob = new PSP_VolumeBalance(); ob.Year = EnsureBaseYear(); ob.TypeID = type; ob.Flag = flag; IList <PSP_VolumeBalance> list0 = Services.BaseService.GetList <PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeIDAndYear", ob); if (list0 != null) { if (list0.Count == 1) { list0[0].S1 = "0"; Services.BaseService.Update <PSP_VolumeBalance>(list0[0]); } } PSP_VolumeBalanceDataSource BaseYearrate = new PSP_VolumeBalanceDataSource(); BaseYearrate.UID = baseyeartype; BaseYearrate.Flag = flag; BaseYearrate.Value = _obj.Year; BaseYearrate.TypeID = Convert.ToInt32(_obj.TypeID); Services.BaseService.Update("UpdatePSP_VolumeBalanceDataSource2", BaseYearrate); } else if (_obj.Year == EnsureBaseYear() /*|| (EnsureBaseYear() == baseyear)*/) { PSP_VolumeBalance ob = new PSP_VolumeBalance(); ob.Flag = flag; ob.TypeID = type; IList <PSP_VolumeBalance> list0 = Services.BaseService.GetList <PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeID", ob); if (list0 != null) { if (list0.Count > 0) { ob = list0[0]; } } PSP_VolumeBalanceDataSource BaseYearrate = new PSP_VolumeBalanceDataSource(); BaseYearrate.Flag = flag; BaseYearrate.UID = baseyeartype; BaseYearrate.Value = baseyear; BaseYearrate.TypeID = Convert.ToInt32(_obj.TypeID); Services.BaseService.Update("UpdatePSP_VolumeBalanceDataSource2", BaseYearrate); PSP_VolumeBalanceDataSource volumtemp = new PSP_VolumeBalanceDataSource(); volumtemp.TypeID = Convert.ToInt32(type); volumtemp.Flag = flag; IList <PSP_VolumeBalanceDataSource> list = Services.BaseService.GetList <PSP_VolumeBalanceDataSource>("SelectPSP_VolumeBalanceDataSourceByTypeID", volumtemp); if (ob != null) { if (ob.UID != "") { foreach (PSP_VolumeBalanceDataSource psptemp in list) { if (psptemp.UID == baseyeartype) { continue; } if (hs[psptemp.Name] != null) { ob.GetType().GetProperty("L" + hs[psptemp.Name].ToString()).SetValue(ob, psptemp.Value, null); } } } } try { ob.S1 = "1"; Services.BaseService.Update <PSP_VolumeBalance>(ob); isresum = true; } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } } //操作已成功 return(true); }
private void repositoryItemCheckEdit1_CheckedChanged(object sender, EventArgs e) { DevExpress.XtraEditors.CheckEdit CheckEdit1temp = (DevExpress.XtraEditors.CheckEdit)sender; PSP_VolumeBalanceDataSource volumtemp = new PSP_VolumeBalanceDataSource(); volumtemp.TypeID = Convert.ToInt32(type); volumtemp.Flag = flag; IList <PSP_VolumeBalanceDataSource> list = Services.BaseService.GetList <PSP_VolumeBalanceDataSource>("SelectPSP_VolumeBalanceDataSourceByTypeID", volumtemp); if (CheckEdit1temp.Checked) { for (int i = 0; i < _obj.GetType().GetProperties().Length; i++) { objtemp.GetType().GetProperty(_obj.GetType().GetProperties()[i].Name).SetValue(objtemp, _obj.GetType().GetProperty(_obj.GetType().GetProperties()[i].Name).GetValue(_obj, null), null); } foreach (PSP_VolumeBalanceDataSource psptemp in list) { try { if (psptemp.UID == baseyeartype) { continue; } if (hs[psptemp.Name] != null) { _obj.GetType().GetProperty("L" + hs[psptemp.Name].ToString()).SetValue(_obj, psptemp.Value, null); } } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } } rowL6.Visible = true; _obj.S1 = "1"; } else { //if (list.Count == 5 && hs.Count == 5) //{ // foreach (PSP_VolumeBalanceDataSource psptemp in list) // { // try // { // _obj.GetType().GetProperty("L" + hs[psptemp.Name].ToString()).SetValue(_obj, 0, null); // } // catch (Exception ex) // { // System.Console.WriteLine(ex.ToString()); // } // } //} if (objtemp.Year != 0) { for (int i = 0; i < _obj.GetType().GetProperties().Length; i++) { _obj.GetType().GetProperty(objtemp.GetType().GetProperties()[i].Name).SetValue(_obj, objtemp.GetType().GetProperty(_obj.GetType().GetProperties()[i].Name).GetValue(objtemp, null), null); } } _obj.S1 = "0"; rowL6.Visible = false; } }
private void barA5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FrmBalance_Calc FrmBalance = new FrmBalance_Calc(); FrmBalance.FormTitle = "规划新增变电容量"; FrmBalance.CtrTitle = this.ctrlPSP_VolumeBalance1.GridView.GroupPanelText; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; PSP_VolumeBalance vol = new PSP_VolumeBalance(); if (this.ctrlPSP_VolumeBalance1.GridView.GetRow(this.ctrlPSP_VolumeBalance1.GridView.FocusedRowHandle) != null) { vol = this.ctrlPSP_VolumeBalance1.GridView.GetRow(this.ctrlPSP_VolumeBalance1.GridView.FocusedRowHandle) as PSP_VolumeBalance; FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "3"; FrmBalance.DY = TypeID; if (FrmBalance.FLAG != "") { FrmBalance.ShowDialog(); this.ctrlPSP_VolumeBalance1.RefreshData(); vol.GetType().GetProperty("L11").SetValue(vol, FrmBalance.SUM, null); this.ctrlPSP_VolumeBalance1.reloadsum(vol); } } }
private void sum(PSP_VolumeBalance objtemp) { //PSP_VolumeBalance volumtemp = new PSP_VolumeBalance(); //volumtemp.TypeID =type; //volumtemp.Year = objtemp.Year; //IList<PSP_VolumeBalance> listtemp = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeIDAboveYear", volumtemp); double l6temp = objtemp.L12; double factor = 1; if (type == "35") if (loadrate != "") factor = Convert.ToDouble(loadrate); PSP_VolumeBalance vol = new PSP_VolumeBalance(); vol.Flag=flag; vol.TypeID=type; IList List = Services.BaseService.GetList("SelectPSP_VolumeBalanceByTypeID", vol); DataTable da = DataConverter.ToDataTable(List, typeof(PSP_VolumeBalance)); DataRow[] dr = da.Select("Year>"+objtemp.Year); foreach (DataRow drtemp in dr) { PSP_VolumeBalance psp = new PSP_VolumeBalance(); foreach (DataColumn dm in da.Columns) { psp.GetType().GetProperty(dm.ColumnName).SetValue(psp, drtemp[dm.ColumnName], null); } //psp = psptemp; psp.L6 = Math.Round(l6temp,2); psp.L5 = Math.Round(psp.L1 + psp.L3 - psp.L2 - psp.L4,2); if (psp.L5 != 0) psp.L7 = Math.Round(psp.L6 / (psp.L5 * factor), 2); else psp.L7 = 0; psp.L8 = Math.Round((psp.L5 * factor) * Convert.ToDouble(Volumecalc), 2); psp.L9 = Math.Round(psp.L6 - psp.L8,2); psp.L12 = Math.Round(psp.L6 + psp.L10 + psp.L11,2); if (psp.L5 != 0) psp.L13 = Math.Round(psp.L12 / (psp.L5 * factor), 2); else psp.L13 = 0; l6temp = Math.Round(psp.L12,2); Services.BaseService.Update("UpdatePSP_VolumeBalance2", psp); //foreach (DataColumn dm in da.Columns) //{ // drtemp[dm.ColumnName]= psp.GetType().GetProperty(dm.ColumnName).GetValue(psp, null); //} } }
/// <summary> /// �Ľ������ /// </summary> public void UpdateObject() { //��ȡ������� PSP_VolumeBalance obj = FocusedObject; bool isresum=false; if (obj == null) { return; } //���������һ������ PSP_VolumeBalance objCopy = new PSP_VolumeBalance(); DataConverter.CopyTo<PSP_VolumeBalance>(obj, objCopy); if ((gridView.FocusedColumn.FieldName != "L2"&& gridView.FocusedColumn.FieldName != "L10" && gridView.FocusedColumn.FieldName != "L11")||(gridView.FocusedColumn.FieldName == "L2")&&type!="220") { //ִ���IJ��� using (FrmPSP_VolumeBalanceDialog dlg = new FrmPSP_VolumeBalanceDialog()) { dlg.Type = type; dlg.Flag = flag; dlg.List = gridView.DataSource as IList<PSP_VolumeBalance>; dlg.Object = objCopy; //���� baseyear = ObjectList[0].Year; dlg.BaseYear = baseyear; if (type == "220") { dlg.xtraTabControl1.TabPages[0].Text = "220ǧ���������ƽ���"; dlg.Text = "220ǧ���������ƽ���"; dlg.rowL1.Properties.Caption = "�ۺ���߸���"; dlg.rowL2.Properties.Caption = "ֱ�ӹ��縺��"; dlg.rowL2.Visible = false; dlg.rowL4.Properties.Caption = "��������"; //dlg.rowL3.Visible = false; // dlg.rowL4.Visible = true; dlg.rowL6.Properties.Caption = "����220kV��ѹ�������"; dlg.rowL14.Visible = false; dlg.categoryRow1.Visible = false; dlg.categoryRow2.Visible = false; dlg.categoryRow3.Properties.Caption = "��220kV��ѹ���縺��"; } else if (type == "35") { dlg.xtraTabControl1.TabPages[0].Text = "35ǧ���������ƽ���"; dlg.Text = "35ǧ���������ƽ���"; dlg.rowL1.Properties.Caption = "��������"; dlg.rowL2.Properties.Caption = "����ƽ�⸺��"; dlg.rowL4.Visible = false; dlg.rowL6.Properties.Caption = "����35ǧ���������"; dlg.categoryRow1.Properties.Caption = "����ƽ�⸺��"; dlg.categoryRow2.Visible = false; dlg.categoryRow3.Properties.Caption = "��35ǧ����ѹ���縺��"; } if (dlg.ShowDialog() != DialogResult.OK) { return; } isresum=dlg.IsReSum; } } else { FrmBalance_Calc FrmBalance = new FrmBalance_Calc(); FrmBalance.FormTitle = gridView.FocusedColumn.Caption; FrmBalance.CtrTitle = gridView.GroupPanelText; PSP_VolumeBalance vol = new PSP_VolumeBalance(); if (gridView.GetRow(gridView.FocusedRowHandle) != null) vol = gridView.GetRow(gridView.FocusedRowHandle) as PSP_VolumeBalance; switch (gridView.FocusedColumn.FieldName) { case "L2": FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "1"; FrmBalance.DY = type; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; break; case "L10": FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "2"; FrmBalance.DY = type; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; break; case"L11": FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "3"; FrmBalance.DY = type; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; break; default: break; } if (FrmBalance.FLAG != "") { FrmBalance.ShowDialog(); objCopy.GetType().GetProperty(gridView.FocusedColumn.FieldName).SetValue(objCopy, FrmBalance.SUM, null); } } //�ø������½������ DataConverter.CopyTo<PSP_VolumeBalance>(objCopy, obj); if (isresum) { PSP_VolumeBalance ob = new PSP_VolumeBalance(); ob.TypeID = type; ob.Flag = flag; IList<PSP_VolumeBalance> list0 = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeID", ob); if (list0 != null) if (list0.Count > 0) ob = list0[0]; if(ob.UID!=obj.UID) Services.BaseService.Update("UpdatePSP_VolumeBalance2", obj); reloadsum(ob); } else reloadsum(obj); //ˢ�±�� gridControl.RefreshDataSource(); }
private void sum(PSP_VolumeBalance objtemp) { //PSP_VolumeBalance volumtemp = new PSP_VolumeBalance(); //volumtemp.TypeID =type; //volumtemp.Year = objtemp.Year; //IList<PSP_VolumeBalance> listtemp = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeIDAboveYear", volumtemp); double l6temp = objtemp.L12; double factor = 1; if (type == "35") { if (loadrate != "") { factor = Convert.ToDouble(loadrate); } } PSP_VolumeBalance vol = new PSP_VolumeBalance(); vol.Flag = flag; vol.TypeID = type; IList List = Services.BaseService.GetList("SelectPSP_VolumeBalanceByTypeID", vol); DataTable da = DataConverter.ToDataTable(List, typeof(PSP_VolumeBalance)); DataRow[] dr = da.Select("Year>" + objtemp.Year); foreach (DataRow drtemp in dr) { PSP_VolumeBalance psp = new PSP_VolumeBalance(); foreach (DataColumn dm in da.Columns) { psp.GetType().GetProperty(dm.ColumnName).SetValue(psp, drtemp[dm.ColumnName], null); } //psp = psptemp; psp.L6 = Math.Round(l6temp, 2); psp.L5 = Math.Round(psp.L1 + psp.L3 - psp.L2 - psp.L4, 2); if (psp.L5 != 0) { psp.L7 = Math.Round(psp.L6 / (psp.L5 * factor), 2); } else { psp.L7 = 0; } psp.L8 = Math.Round((psp.L5 * factor) * Convert.ToDouble(Volumecalc), 2); psp.L9 = Math.Round(psp.L6 - psp.L8, 2); psp.L12 = Math.Round(psp.L6 + psp.L10 + psp.L11, 2); if (psp.L5 != 0) { psp.L13 = Math.Round(psp.L12 / (psp.L5 * factor), 2); } else { psp.L13 = 0; } l6temp = Math.Round(psp.L12, 2); Services.BaseService.Update("UpdatePSP_VolumeBalance2", psp); //foreach (DataColumn dm in da.Columns) //{ // drtemp[dm.ColumnName]= psp.GetType().GetProperty(dm.ColumnName).GetValue(psp, null); //} } }
/// <summary> /// 修改焦点对象 /// </summary> public void UpdateObject() { //获取焦点对象 PSP_VolumeBalance obj = FocusedObject; bool isresum = false; if (obj == null) { return; } //创建对象的一个副本 PSP_VolumeBalance objCopy = new PSP_VolumeBalance(); DataConverter.CopyTo <PSP_VolumeBalance>(obj, objCopy); if ((gridView.FocusedColumn.FieldName != "L2" && gridView.FocusedColumn.FieldName != "L10" && gridView.FocusedColumn.FieldName != "L11") || (gridView.FocusedColumn.FieldName == "L2") && type != "220") { //执行修改操作 using (FrmPSP_VolumeBalanceDialog dlg = new FrmPSP_VolumeBalanceDialog()) { dlg.Type = type; dlg.Flag = flag; dlg.List = gridView.DataSource as IList <PSP_VolumeBalance>; dlg.Object = objCopy; //绑定副本 baseyear = ObjectList[0].Year; dlg.BaseYear = baseyear; if (type == "220") { dlg.xtraTabControl1.TabPages[0].Text = "220千伏变电容量平衡表"; dlg.Text = "220千伏变电容量平衡表"; dlg.rowL1.Properties.Caption = "综合最高负荷"; dlg.rowL2.Properties.Caption = "直接供电负荷"; dlg.rowL2.Visible = false; dlg.rowL4.Properties.Caption = "外网供电"; //dlg.rowL3.Visible = false; // dlg.rowL4.Visible = true; dlg.rowL6.Properties.Caption = "现有220kV降压变电容量"; dlg.rowL14.Visible = false; dlg.categoryRow1.Visible = false; dlg.categoryRow2.Visible = false; dlg.categoryRow3.Properties.Caption = "需220kV降压供电负荷"; } else if (type == "35") { dlg.xtraTabControl1.TabPages[0].Text = "35千伏变电容量平衡表"; dlg.Text = "35千伏变电容量平衡表"; dlg.rowL1.Properties.Caption = "本区负荷"; dlg.rowL2.Properties.Caption = "本地平衡负荷"; dlg.rowL4.Visible = false; dlg.rowL6.Properties.Caption = "现有35千伏变电容量"; dlg.categoryRow1.Properties.Caption = "本地平衡负荷"; dlg.categoryRow2.Visible = false; dlg.categoryRow3.Properties.Caption = "需35千伏降压供电负荷"; } if (dlg.ShowDialog() != DialogResult.OK) { return; } isresum = dlg.IsReSum; } } else { FrmBalance_Calc FrmBalance = new FrmBalance_Calc(); FrmBalance.FormTitle = gridView.FocusedColumn.Caption; FrmBalance.CtrTitle = gridView.GroupPanelText; PSP_VolumeBalance vol = new PSP_VolumeBalance(); if (gridView.GetRow(gridView.FocusedRowHandle) != null) { vol = gridView.GetRow(gridView.FocusedRowHandle) as PSP_VolumeBalance; } switch (gridView.FocusedColumn.FieldName) { case "L2": FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "1"; FrmBalance.DY = type; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; break; case "L10": FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "2"; FrmBalance.DY = type; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; break; case "L11": FrmBalance.FLAG = vol.UID; FrmBalance.TYPE = "3"; FrmBalance.DY = type; FrmBalance.ADdRight = AddRight; FrmBalance.EDitRight = EditRight; FrmBalance.DEleteRight = DeleteRight; FrmBalance.PRintRight = PrintRight; break; default: break; } if (FrmBalance.FLAG != "") { FrmBalance.ShowDialog(); objCopy.GetType().GetProperty(gridView.FocusedColumn.FieldName).SetValue(objCopy, FrmBalance.SUM, null); } } //用副本更新焦点对象 DataConverter.CopyTo <PSP_VolumeBalance>(objCopy, obj); if (isresum) { PSP_VolumeBalance ob = new PSP_VolumeBalance(); ob.TypeID = type; ob.Flag = flag; IList <PSP_VolumeBalance> list0 = Services.BaseService.GetList <PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeID", ob); if (list0 != null) { if (list0.Count > 0) { ob = list0[0]; } } if (ob.UID != obj.UID) { Services.BaseService.Update("UpdatePSP_VolumeBalance2", obj); } reloadsum(ob); } else { reloadsum(obj); } //刷新表格 gridControl.RefreshDataSource(); }