Exemple #1
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            Ps_Power obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

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

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

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

            //用副本更新焦点对象
            DataConverter.CopyTo <Ps_Power>(objCopy, obj);
            //刷新表格
            RefreshData();
            gridControl.RefreshDataSource();
        }
Exemple #2
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            if (ObjectList == null)
            {
                return;
            }
            //新建对象
            Ps_Power obj = new Ps_Power();

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

            //将新对象加入到链表中
            ObjectList.Add(obj);
            RefreshData();
            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
        }
Exemple #3
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            Ps_Power obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

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

            //执行删除操作
            try
            {
                Services.BaseService.Delete <Ps_Power>(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();
        }
        private void InitData()
        {
            Ps_Power ps = this.ctrlPs_Substation_As1.FocusedObject;

            if (ps == null)
            {
                return;
            }
            ps.Col4 = glys.ToString("n2");
            gridColumn4.FieldName = "y" + year;

            double zdfh = 0;
            object obj  = ps.GetType().GetProperty("y" + year).GetValue(ps, null);

            if (obj != null)
            {
                zdfh = Convert.ToDouble(obj);
            }
            double xgl = 0;

            try
            {
                xgl = Convert.ToDouble(ps.Col3);
            }catch {}
            int xhl = 0;

            try
            {
                xhl = Convert.ToInt32(ps.Col2);
            }
            catch { }

            ps.Col9 = (xgl * (xhl - 1) - zdfh / glys).ToString("n2");


            if (xgl == 0 || xhl == 0)
            {
                ps.Col8 = "0";
            }
            else
            {
                ps.Col8 = (zdfh / (xgl * xhl * glys)).ToString("n2");
            }


            object obj1 = ps.GetType().GetProperty("y" + (year + 1)).GetValue(ps, null);
            object obj2 = ps.GetType().GetProperty("y" + (year + 2)).GetValue(ps, null);
            object obj3 = ps.GetType().GetProperty("y" + (year + 3)).GetValue(ps, null);
            object obj4 = ps.GetType().GetProperty("y" + (year + 4)).GetValue(ps, null);
            object obj5 = ps.GetType().GetProperty("y" + (year + 5)).GetValue(ps, null);

            double ob1 = 0;
            double ob2 = 0;
            double ob3 = 0;
            double ob4 = 0;
            double ob5 = 0;

            if (obj1 != null)
            {
                ob1 = Convert.ToDouble(obj1);
            }
            if (obj2 != null)
            {
                ob2 = Convert.ToDouble(obj2);
            }
            if (obj3 != null)
            {
                ob3 = Convert.ToDouble(obj3);
            }
            if (obj4 != null)
            {
                ob4 = Convert.ToDouble(obj4);
            }
            if (obj5 != null)
            {
                ob5 = Convert.ToDouble(obj5);
            }


            PropertyInfo pi1  = ps.GetType().GetProperty("m" + (year + 1));
            PropertyInfo pi11 = ps.GetType().GetProperty("n" + (year + 1));
            PropertyInfo pi2  = ps.GetType().GetProperty("m" + (year + 2));
            PropertyInfo pi22 = ps.GetType().GetProperty("n" + (year + 2));
            PropertyInfo pi3  = ps.GetType().GetProperty("m" + (year + 3));
            PropertyInfo pi33 = ps.GetType().GetProperty("n" + (year + 3));
            PropertyInfo pi4  = ps.GetType().GetProperty("m" + (year + 4));
            PropertyInfo pi44 = ps.GetType().GetProperty("n" + (year + 4));
            PropertyInfo pi5  = ps.GetType().GetProperty("m" + (year + 5));
            PropertyInfo pi55 = ps.GetType().GetProperty("n" + (year + 5));

            pi11.SetValue(ps, xgl * (xhl - 1) - ob1 / glys, null);
            pi22.SetValue(ps, xgl * (xhl - 1) - ob2 / glys, null);
            pi33.SetValue(ps, xgl * (xhl - 1) - ob3 / glys, null);
            pi44.SetValue(ps, xgl * (xhl - 1) - ob4 / glys, null);
            pi55.SetValue(ps, xgl * (xhl - 1) - ob5 / glys, null);

            if (xgl == 0 || xhl == 0)
            {
                pi1.SetValue(ps, 0, null);
                pi2.SetValue(ps, 0, null);
                pi3.SetValue(ps, 0, null);
                pi4.SetValue(ps, 0, null);
                pi5.SetValue(ps, 0, null);
            }
            else
            {
                pi1.SetValue(ps, ob1 / (xgl * xhl * glys), null);
                pi2.SetValue(ps, ob2 / (xgl * xhl * glys), null);
                pi3.SetValue(ps, ob3 / (xgl * xhl * glys), null);
                pi4.SetValue(ps, ob4 / (xgl * xhl * glys), null);
                pi5.SetValue(ps, ob5 / (xgl * xhl * glys), null);
            }



            IList <Ps_Power> li  = new List <Ps_Power>();
            Ps_Power         ps1 = new Ps_Power();
            Ps_Power         ps2 = new Ps_Power();
            Ps_Power         ps3 = new Ps_Power();

            DataConverter.CopyTo <Ps_Power>(ps, ps1);
            DataConverter.CopyTo <Ps_Power>(ps, ps2);
            DataConverter.CopyTo <Ps_Power>(ps, ps3);
            switch (xhl)
            {
            case 2:

                li.Add(ps);
                li.Add(ps1);
                break;

            case 3:
                li.Add(ps);
                li.Add(ps1);
                li.Add(ps2);

                break;

            case 4:
                li.Add(ps);
                li.Add(ps1);
                li.Add(ps2);
                li.Add(ps3);
                break;

            default:
                li.Add(ps);
                li.Add(ps1);
                break;
            }



            this.gridControl1.DataSource = li;
        }
        private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmFX    ff = new FrmFX();
            Ps_Power ps = this.ctrlPs_Substation_As1.FocusedObject;

            if (ps == null)
            {
                return;
            }

            double bfzl = 0;

            try { bfzl = Convert.ToDouble(ps.Col5); }
            catch { }

            double xfzl = 0;

            try { xfzl = Convert.ToDouble(ps.Col8); }
            catch { }

            if (bfzl >= 1)
            {
                ff.S1 = "音諾怎";
            }
            else
            {
                ff.S1 = "諾怎";
            }
            ff.S3 = ps.Col7 + "定坪";

            if (xfzl >= 1)
            {
                ff.S2 = "音諾怎";
            }
            else
            {
                ff.S2 = "諾怎";
            }


            object obj1 = ps.GetType().GetProperty("n" + (year + 1)).GetValue(ps, null);
            object obj2 = ps.GetType().GetProperty("n" + (year + 2)).GetValue(ps, null);
            object obj3 = ps.GetType().GetProperty("n" + (year + 3)).GetValue(ps, null);
            object obj4 = ps.GetType().GetProperty("n" + (year + 4)).GetValue(ps, null);
            object obj5 = ps.GetType().GetProperty("n" + (year + 5)).GetValue(ps, null);

            double ob1 = 0;
            double ob2 = 0;
            double ob3 = 0;
            double ob4 = 0;
            double ob5 = 0;

            if (obj1 != null)
            {
                ob1 = Convert.ToDouble(obj1);
            }
            if (obj2 != null)
            {
                ob2 = Convert.ToDouble(obj2);
            }
            if (obj3 != null)
            {
                ob3 = Convert.ToDouble(obj3);
            }
            if (obj4 != null)
            {
                ob4 = Convert.ToDouble(obj4);
            }
            if (obj5 != null)
            {
                ob5 = Convert.ToDouble(obj5);
            }
            ff.S4 = "5定坪";
            if (ob5 < 0)
            {
                ff.S4 = "5定坪";
            }
            if (ob4 < 0)
            {
                ff.S4 = "4定坪";
            }
            if (ob3 < 0)
            {
                ff.S4 = "3定坪";
            }
            if (ob2 < 0)
            {
                ff.S4 = "2定坪";
            }
            if (ob1 < 0)
            {
                ff.S4 = "1定坪";
            }

            ff.ShowDialog();
        }
        /// <summary>
        /// ��Ӷ���
        /// </summary>
        public void AddObject()
        {
            //�����������Ƿ��Ѿ�����
            if (ObjectList == null)
            {
                return;
            }
            //�½�����
            Ps_Power obj = new Ps_Power();
            obj.Type = type;
            obj.ID = Guid.NewGuid().ToString();
            //ִ����Ӳ���
            using (FrmPs_Substation_AsDialog dlg = new FrmPs_Substation_AsDialog())
            {
                dlg.IsCreate = true;    //�����½���־
                dlg.Object = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //���¶�����뵽������
            ObjectList.Add(obj);
            RefreshData();
            //ˢ�±�񣬲��������ж�λ���¶����ϡ�
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
        }
        /// <summary>
        /// �޸Ľ������
        /// </summary>
        public void UpdateObject()
        {
            //��ȡ�������
            Ps_Power obj = FocusedObject;
            if (obj == null)
            {
                return;
            }

            //���������һ������
            Ps_Power objCopy = new Ps_Power();
            DataConverter.CopyTo<Ps_Power>(obj, objCopy);

            //ִ���޸IJ���
            using (FrmPs_Substation_AsDialog dlg = new FrmPs_Substation_AsDialog())
            {
                dlg.Object = objCopy;   //�󶨸���
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //�ø������½������
            DataConverter.CopyTo<Ps_Power>(objCopy, obj);
            //ˢ�±��
            RefreshData();
            gridControl.RefreshDataSource();
        }
        private void InitData()
        {
            Ps_Power ps = this.ctrlPs_Substation_As1.FocusedObject;
            if (ps == null)
                return;
            ps.Col4 = glys.ToString("n2");
            gridColumn4.FieldName = "y" + year;

            double zdfh = 0;
            object obj = ps.GetType().GetProperty("y" + year).GetValue(ps, null);
            if (obj != null)
            {
                zdfh = Convert.ToDouble(obj);
            }
            double xgl = 0;
            try
            {
                xgl = Convert.ToDouble(ps.Col3);
            }catch{}
            int xhl = 0;
            try
            {
                xhl = Convert.ToInt32(ps.Col2);
            }
            catch { }

            ps.Col9 = (xgl*(xhl-1) - zdfh / glys).ToString("n2");

            if (xgl == 0 || xhl == 0)
                ps.Col8 = "0";
            else
                ps.Col8 = (zdfh / (xgl * xhl * glys)).ToString("n2");

            object obj1 = ps.GetType().GetProperty("y" + (year + 1)).GetValue(ps, null);
            object obj2 = ps.GetType().GetProperty("y" + (year + 2)).GetValue(ps, null);
            object obj3 = ps.GetType().GetProperty("y" + (year + 3)).GetValue(ps, null);
            object obj4 = ps.GetType().GetProperty("y" + (year + 4)).GetValue(ps, null);
            object obj5 = ps.GetType().GetProperty("y" + (year + 5)).GetValue(ps, null);

            double ob1 = 0;
            double ob2 = 0;
            double ob3 = 0;
            double ob4 = 0;
            double ob5 = 0;

            if (obj1 != null)
            {
                ob1 = Convert.ToDouble(obj1);
            }
            if (obj2 != null)
            {
                ob2 = Convert.ToDouble(obj2);
            }
            if (obj3 != null)
            {
                ob3 = Convert.ToDouble(obj3);
            }
            if (obj4 != null)
            {
                ob4 = Convert.ToDouble(obj4);
            }
            if (obj5 != null)
            {
                ob5 = Convert.ToDouble(obj5);
            }

            PropertyInfo pi1 = ps.GetType().GetProperty("m" + (year + 1));
            PropertyInfo pi11 = ps.GetType().GetProperty("n" + (year + 1));
            PropertyInfo pi2 = ps.GetType().GetProperty("m" + (year + 2));
            PropertyInfo pi22 = ps.GetType().GetProperty("n" + (year + 2));
            PropertyInfo pi3 = ps.GetType().GetProperty("m" + (year + 3));
            PropertyInfo pi33 = ps.GetType().GetProperty("n" + (year + 3));
            PropertyInfo pi4 = ps.GetType().GetProperty("m" + (year + 4));
            PropertyInfo pi44 = ps.GetType().GetProperty("n" + (year + 4));
            PropertyInfo pi5 = ps.GetType().GetProperty("m" + (year + 5));
            PropertyInfo pi55 = ps.GetType().GetProperty("n" + (year + 5));

            pi11.SetValue(ps, xgl * (xhl - 1) - ob1 / glys, null);
            pi22.SetValue(ps, xgl * (xhl - 1) - ob2 / glys, null);
            pi33.SetValue(ps, xgl * (xhl - 1) - ob3 / glys, null);
            pi44.SetValue(ps, xgl * (xhl - 1) - ob4 / glys, null);
            pi55.SetValue(ps, xgl * (xhl - 1) - ob5 / glys, null);

            if (xgl == 0 || xhl == 0)
            {
                pi1.SetValue(ps, 0, null);
                pi2.SetValue(ps, 0, null);
                pi3.SetValue(ps, 0, null);
                pi4.SetValue(ps, 0, null);
                pi5.SetValue(ps, 0, null);

            }
            else
            {
                pi1.SetValue(ps, ob1 / (xgl * xhl * glys), null);
                pi2.SetValue(ps, ob2 / (xgl * xhl * glys), null);
                pi3.SetValue(ps, ob3 / (xgl * xhl * glys), null);
                pi4.SetValue(ps, ob4 / (xgl * xhl * glys), null);
                pi5.SetValue(ps, ob5 / (xgl * xhl * glys), null);

            }

            IList<Ps_Power> li = new List<Ps_Power>();
            Ps_Power ps1 = new Ps_Power();
            Ps_Power ps2 = new Ps_Power();
            Ps_Power ps3 = new Ps_Power();
            DataConverter.CopyTo<Ps_Power>(ps, ps1);
            DataConverter.CopyTo<Ps_Power>(ps, ps2);
            DataConverter.CopyTo<Ps_Power>(ps, ps3);
            switch (xhl)
            {
                case 2:

                    li.Add(ps);
                    li.Add(ps1);
                    break;
                case 3:
                    li.Add(ps);
                    li.Add(ps1);
                    li.Add(ps2);

                    break;
                case 4:
                    li.Add(ps);
                    li.Add(ps1);
                    li.Add(ps2);
                    li.Add(ps3);
                    break;
                default:
                    li.Add(ps);
                    li.Add(ps1);
                    break;

            }

            this.gridControl1.DataSource = li;
        }