/// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            if (ObjectList == null)
            {
                return;
            }
            //新建对象
            PSP_35KVPingHeng obj = new PSP_35KVPingHeng();

            //执行添加操作
            using (FrmPSP_35KVPingHengDialog dlg = new FrmPSP_35KVPingHengDialog())
            {
                dlg.IsCreate = true;                    //设置新建标志
                dlg.Object   = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //将新对象加入到链表中
            ObjectList.Add(obj);

            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
        }
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            PSP_35KVPingHeng obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //创建对象的一个副本
            PSP_35KVPingHeng objCopy = new PSP_35KVPingHeng();

            DataConverter.CopyTo <PSP_35KVPingHeng>(obj, objCopy);

            //执行修改操作
            using (FrmPSP_35KVPingHengDialog dlg = new FrmPSP_35KVPingHengDialog())
            {
                dlg.Object = objCopy;                   //绑定副本
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //用副本更新焦点对象
            DataConverter.CopyTo <PSP_35KVPingHeng>(objCopy, obj);
            //刷新表格
            gridControl.RefreshDataSource();
        }
Beispiel #3
0
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //删除年


            GridColumn gc = this.gridView.FocusedColumn;

            if (gc == null)
            {
                return;
            }
            if (gc.FieldName.Substring(0, 1) != "L")
            {
                MsgBox.Show("不能删除固定列");
                return;
            }

            if (MsgBox.ShowYesNo("是否删除 " + gc.Caption + " 的所有数据?") != DialogResult.Yes)
            {
                return;
            }


            foreach (GridColumn gc1 in this.gridView.Columns)
            {
                try
                {
                    if (gc1.Name == gc.Name)
                    {
                        gc1.Visible = false;
                    }
                }
                catch { }
            }



            gc.OptionsColumn.ShowInCustomizationForm = false;
            PSP_35KVPingHeng si = new PSP_35KVPingHeng();

            si.Title = gc.FieldName + "=0";
            si.Type  = type;
            Itop.Client.Common.Services.BaseService.Update("UpdatePSP_35KVPingHengByTypeWhere", si);

            PSP_35KVStyle psl = new PSP_35KVStyle();

            psl.ClassType = gc.FieldName;
            psl.Type      = type;
            psl.Title     = gc.Caption;
            Itop.Client.Common.Services.BaseService.Update("DeletePSP_35KVStyleByAll", psl);
        }
Beispiel #4
0
        private void gridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            object obj = this.gridView.GetRow(this.gridView.FocusedRowHandle);

            if (obj == null)
            {
                return;
            }

            PSP_35KVPingHeng p35 = (PSP_35KVPingHeng)obj;

            Services.BaseService.Update <PSP_35KVPingHeng>(p35);
            InitData();
        }
Beispiel #5
0
        private void gridView_ShowingEditor(object sender, CancelEventArgs e)
        {
            object obj = this.gridView.GetRow(this.gridView.FocusedRowHandle);

            if (obj == null)
            {
                return;
            }

            PSP_35KVPingHeng p35 = (PSP_35KVPingHeng)obj;

            if (p35.Title == "全县" || p35.SortID2 == 3 || p35.SortID2 == 6)
            {
                e.Cancel = true;
            }
        }
Beispiel #6
0
        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //添加地区
            PSP_35KVPingHeng p35 = new PSP_35KVPingHeng();

            p35.Type = type;

            using (FrmPSP_35KVPingHengDialog dlg = new FrmPSP_35KVPingHengDialog())
            {
                dlg.IsCreate = true;                    //设置新建标志
                dlg.Object   = p35;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                InitData();
            }
        }
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            PSP_35KVPingHeng obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                Services.BaseService.Delete <PSP_35KVPingHeng>(obj);
            }
            catch (Exception exc)
            {
                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();
        }
Beispiel #8
0
        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //删除地区
            //获取焦点对象
            //修改地区
            object obj = this.gridView.GetRow(this.gridView.FocusedRowHandle);

            if (obj == null)
            {
                return;
            }

            PSP_35KVPingHeng objCopy = (PSP_35KVPingHeng)obj;

            objCopy.Title = objCopy.DiQu;

            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                Services.BaseService.Update("UpdatePSP_35KVPingHengByTypeAndTitleByDelete", obj);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }

            InitData();
        }
Beispiel #9
0
        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //修改地区
            object obj = this.gridView.GetRow(this.gridView.FocusedRowHandle);

            if (obj == null)
            {
                return;
            }

            PSP_35KVPingHeng objCopy = (PSP_35KVPingHeng)obj;

            objCopy.Title = objCopy.DiQu;

            using (FrmPSP_35KVPingHengDialog dlg = new FrmPSP_35KVPingHengDialog())
            {
                dlg.Object = objCopy;   //绑定副本
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                InitData();
            }
        }
Beispiel #10
0
        private void InitData()
        {
            IList <PSP_35KVPingHeng> list = Services.BaseService.GetList <PSP_35KVPingHeng>("SelectPSP_35KVPingHengByType", type);
            //this.gridControl.DataSource = list;

            string s1 = "";
            string s2 = "";



            int cou = list.Count;
            int ss  = cou / 4;

            DateTime         dtime = DateTime.Now;
            PSP_35KVPingHeng p31   = new PSP_35KVPingHeng();

            p31.SortID1    = "全县";
            p31.DiQu       = "全县";
            p31.Title      = "最大供电负荷";
            p31.SortID2    = 1;
            p31.CreateTime = dtime;

            PSP_35KVPingHeng p32 = new PSP_35KVPingHeng();

            p32.SortID1    = "全县";
            p32.DiQu       = "全县";
            p32.Title      = "本地平衡负荷";
            p32.SortID2    = 2;
            p32.CreateTime = dtime;

            PSP_35KVPingHeng p33 = new PSP_35KVPingHeng();

            p33.SortID1    = "全县";
            p33.DiQu       = "全县";
            p33.Title      = "需要35千伏受电电力";
            p33.SortID2    = 3;
            p33.CreateTime = dtime;

            PSP_35KVPingHeng p34 = new PSP_35KVPingHeng();

            p34.SortID1    = "全县";
            p34.DiQu       = "全县";
            p34.Title      = "需要35千伏变电容量";
            p34.SortID2    = 4;
            p34.CreateTime = dtime;

            PSP_35KVPingHeng p35 = new PSP_35KVPingHeng();

            p35.SortID1    = "全县";
            p35.DiQu       = "全县";
            p35.Title      = "已有35千伏变电容量";
            p35.SortID2    = 5;
            p35.CreateTime = dtime;

            PSP_35KVPingHeng p36 = new PSP_35KVPingHeng();

            p36.SortID1    = "全县";
            p36.DiQu       = "全县";
            p36.Title      = "需新增35千伏变电容量";
            p36.SortID2    = 6;
            p36.CreateTime = dtime;



            for (int i = 0; i < ss; i++)
            {
                PSP_35KVPingHeng p1 = list[4 * i];
                PSP_35KVPingHeng p2 = list[4 * i + 1];
                PSP_35KVPingHeng p3 = list[4 * i + 2];
                PSP_35KVPingHeng p4 = list[4 * i + 3];

                PSP_35KVPingHeng p5 = new PSP_35KVPingHeng();
                p5.UID        = Guid.NewGuid().ToString();
                p5.SortID1    = p1.SortID1;
                p5.SortID2    = 3;
                p5.DiQu       = p1.DiQu;
                p5.Title      = "需要35千伏受电电力";
                p5.CreateTime = p1.CreateTime;

                PSP_35KVPingHeng p6 = new PSP_35KVPingHeng();
                p6.UID        = Guid.NewGuid().ToString();
                p6.SortID1    = p1.SortID1;
                p6.SortID2    = 6;
                p6.DiQu       = p1.DiQu;
                p6.Title      = "需新增35千伏变电容量";
                p6.CreateTime = p1.CreateTime;

                for (int j = 1; j <= 40; j++)
                {
                    double d1 = 0;
                    double d2 = 0;
                    double d3 = 0;
                    double d4 = 0;

                    double d31 = 0;
                    double d32 = 0;
                    double d33 = 0;
                    double d34 = 0;
                    double d35 = 0;
                    double d36 = 0;

                    try{
                        d1 = (double)p1.GetType().GetProperty("L" + j).GetValue(p1, null);
                    }catch {}
                    try{
                        d2 = (double)p2.GetType().GetProperty("L" + j).GetValue(p2, null);
                    }catch {}
                    try{
                        d3 = (double)p3.GetType().GetProperty("L" + j).GetValue(p3, null);
                    }catch {}
                    try{
                        d4 = (double)p4.GetType().GetProperty("L" + j).GetValue(p4, null);
                    }catch {}

                    try
                    {
                        d31 = (double)p31.GetType().GetProperty("L" + j).GetValue(p31, null);
                    }
                    catch { }

                    try
                    {
                        d32 = (double)p32.GetType().GetProperty("L" + j).GetValue(p32, null);
                    }
                    catch { }

                    try
                    {
                        d33 = (double)p33.GetType().GetProperty("L" + j).GetValue(p33, null);
                    }
                    catch { }

                    try
                    {
                        d34 = (double)p34.GetType().GetProperty("L" + j).GetValue(p34, null);
                    }
                    catch { }

                    try
                    {
                        d35 = (double)p35.GetType().GetProperty("L" + j).GetValue(p35, null);
                    }
                    catch { }

                    try
                    {
                        d36 = (double)p36.GetType().GetProperty("L" + j).GetValue(p36, null);
                    }
                    catch { }

                    p5.GetType().GetProperty("L" + j).SetValue(p5, d1 - d2, null);
                    p6.GetType().GetProperty("L" + j).SetValue(p6, d3 - d4, null);


                    p31.GetType().GetProperty("L" + j).SetValue(p31, d31 + d1, null);
                    p32.GetType().GetProperty("L" + j).SetValue(p32, d32 + d2, null);
                    p33.GetType().GetProperty("L" + j).SetValue(p33, d33 + d1 - d2, null);
                    p34.GetType().GetProperty("L" + j).SetValue(p34, d34 + d3, null);
                    p35.GetType().GetProperty("L" + j).SetValue(p35, d35 + d4, null);
                    p36.GetType().GetProperty("L" + j).SetValue(p36, d36 + d3 - d4, null);
                }
                list.Add(p5);
                list.Add(p6);
            }

            list.Add(p31);
            list.Add(p32);
            list.Add(p33);
            list.Add(p34);
            list.Add(p35);
            list.Add(p36);

            gridControl.DataSource = list;
            InitVisuble();
        }