예제 #1
0
        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;
        }
예제 #2
0
        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();
        }