Exemple #1
0
        //private static IOraService oraService;

        //public static IOraService OraService
        //{
        //    get
        //    {
        //        if (oraService == null)
        //        {
        //            oraService = RemotingHelper.GetRemotingService<IOraService>();
        //        }
        //        if (oraService == null) MsgBox.Show("服务没有注册");
        //        return OraService;
        //    }
        //}

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            IOraService OraService = RemotingHelper.GetRemotingService <IOraService>();

            try
            {
                FlashWindow frmLoad = new FlashWindow();
                //f.SetText("计算中请等待。");
                frmLoad.Show();
                frmLoad.RefleshStatus("计算中请等待...");
                //Application.DoEvents();
                frmLoad.SplashData();
                string str_sql  = "";
                string selYear  = year.Text;
                string selMonth = month.Text;

                string StartDate = "";
                string EndDate   = "";
                IList  list2     = new List <PSP_interface>();
                if (selMonth != "全部")
                {
                    StartDate = selYear + "-" + selMonth + "-01 00:00:00";
                    EndDate   = selYear + "-" + selMonth + "-31 23:59:59";
                    str_sql   = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " +
                                "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                                "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";


                    //con = GetConn();
                    DataSet d = OraService.GetDataSet(str_sql, connstr); // GetDataSet(str_sql);

                    for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                    {
                        PSP_interface p = new PSP_interface();
                        p.UMonth = month.Text;
                        p.UYear  = Convert.ToInt32(year.Text);
                        if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                        {
                            p.Number = 0;
                        }
                        else
                        {
                            p.Number = Convert.ToDouble(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][3]) / 10000, 2));
                        }
                        if (Convert.IsDBNull(d.Tables[0].Rows[i][4]))
                        {
                            p.col1 = "0";
                        }
                        else
                        {
                            p.col1 = Convert.ToString(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][4]) / 10000, 2));
                        }
                        p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                        p.Switch_Id       = d.Tables[0].Rows[i][1].ToString();
                        p.Switch_Name     = d.Tables[0].Rows[i][2].ToString();
                        p.UID             = Guid.NewGuid().ToString();
                        list2.Add(p);
                    }
                    str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear + selMonth + " a,switch b,substation c " +
                              "where b.substation_id=c.id and b.id=a.mp_id and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                              "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                    DataSet d2 = OraService.GetDataSet(str_sql, connstr);
                    for (int i = 0; i < d2.Tables[0].Rows.Count; i++)
                    {
                        PSP_interface p = new PSP_interface();
                        //p.UMonth = month.Text;
                        //p.UYear = Convert.ToInt32(year.Text);
                        //if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                        //{
                        //    p.Number = 0;
                        //}
                        //else
                        //{
                        //    p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]);
                        //}
                        if (Convert.IsDBNull(d2.Tables[0].Rows[i][3]))
                        {
                            p.LoadValue = 0;
                        }
                        else
                        {
                            p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]), 2));
                        }
                        //p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                        //p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                        //p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                        //p.UID = Guid.NewGuid().ToString();
                        ((PSP_interface)list2[i]).LoadValue = p.LoadValue;;
                    }

                    ctrlglebeType1.GridControl.DataSource = list2;
                }
                else
                {
                    try
                    {
                        for (int n = 1; n < 13; n++)
                        {
                            string mm = n.ToString();
                            if (mm.Length < 2)
                            {
                                mm = "0" + mm;
                            }
                            StartDate = selYear + "-" + mm + "-01 00:00:00";
                            EndDate   = selYear + "-" + mm + "-31 23:59:59";
                            str_sql   = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " +
                                        "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                                        "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                            //con = GetConn();
                            DataSet d = OraService.GetDataSet(str_sql, connstr);
                            for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                            {
                                PSP_interface p = new PSP_interface();
                                p.UMonth = mm;
                                p.UYear  = Convert.ToInt32(year.Text);
                                if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                                {
                                    p.Number = 0;
                                }
                                else
                                {
                                    p.Number = Convert.ToDouble(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][3]) / 10000, 2));
                                }

                                if (Convert.IsDBNull(d.Tables[0].Rows[i][4]))
                                {
                                    p.col1 = "0";
                                }
                                else
                                {
                                    p.col1 = Convert.ToString(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][4]) / 10000, 2));
                                }
                                p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                                p.Switch_Id       = d.Tables[0].Rows[i][1].ToString();
                                p.Switch_Name     = d.Tables[0].Rows[i][2].ToString();
                                p.UID             = Guid.NewGuid().ToString();
                                list2.Add(p);
                            }
                            str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear + mm + " a,switch b,substation c " +
                                      "where b.substation_id=c.id and b.id=a.mp_id  and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                                      "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                            //con = GetConn();
                            DataSet d2 = OraService.GetDataSet(str_sql, connstr);
                            for (int i = 0; i < d2.Tables[0].Rows.Count; i++)
                            {
                                PSP_interface p = new PSP_interface();
                                //p.UMonth = mm;
                                //p.UYear = Convert.ToInt32(year.Text);
                                //if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                                //{
                                //    p.Number = 0;
                                //}
                                //else
                                //{
                                //    p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]);
                                //}
                                if (Convert.IsDBNull(d2.Tables[0].Rows[i][3]))
                                {
                                    p.LoadValue = 0;
                                }
                                else
                                {
                                    p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]), 2));
                                }
                                //p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                                //p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                                //p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                                //p.UID = Guid.NewGuid().ToString();
                                ((PSP_interface)list2[i]).LoadValue = p.LoadValue;
                            }
                        }
                    }
                    catch (Exception ex) {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        ctrlglebeType1.GridControl.DataSource = list2;
                    }
                }
                if (list2.Count > 0)
                {
                }
                else
                {
                }
                frmLoad.Close();
            }
            catch (Exception e1) {
                MessageBox.Show("没有找到相关信息,请重新选择时间。" + e1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #2
0
        //private static IOraService oraService;
        //public static IOraService OraService
        //{
        //    get
        //    {
        //        if (oraService == null)
        //        {
        //            oraService = RemotingHelper.GetRemotingService<IOraService>();
        //        }
        //        if (oraService == null) MsgBox.Show("����û��ע��");
        //        return OraService;
        //    }
        //}
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            IOraService OraService = RemotingHelper.GetRemotingService<IOraService>();
            try
            {
                FlashWindow frmLoad = new FlashWindow();
                //f.SetText("��������ȴ���");
                frmLoad.Show();
                frmLoad.RefleshStatus("��������ȴ�...");
                //Application.DoEvents();
                frmLoad.SplashData();
                string str_sql = "";
                string selYear = year.Text;
                string selMonth = month.Text;

                string StartDate = "";
                string EndDate = "";
                IList list2 = new List<PSP_interface>();
                if (selMonth != "ȫ��")
                {
                    StartDate = selYear + "-" + selMonth + "-01 00:00:00";
                    EndDate = selYear + "-" + selMonth + "-31 23:59:59";
                    str_sql = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " +
                     "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                     "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";

                    //con = GetConn();
                    DataSet d = OraService.GetDataSet(str_sql, connstr); // GetDataSet(str_sql);

                    for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                    {
                        PSP_interface p = new PSP_interface();
                        p.UMonth = month.Text;
                        p.UYear = Convert.ToInt32(year.Text);
                        if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                        {
                            p.Number = 0;
                        }
                        else
                        {
                            p.Number =Convert.ToDouble(Math.Round( Convert.ToDouble(d.Tables[0].Rows[i][3])/10000,2));
                        }
                        if (Convert.IsDBNull(d.Tables[0].Rows[i][4]))
                        {
                            p.col1 = "0";
                        }
                        else
                        {

                            p.col1 =Convert.ToString(Math.Round( Convert.ToDouble(d.Tables[0].Rows[i][4])/10000,2));
                        }
                        p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                        p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                        p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                        p.UID = Guid.NewGuid().ToString();
                        list2.Add(p);
                    }
                    str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear +selMonth+ " a,switch b,substation c " +
                   "where b.substation_id=c.id and b.id=a.mp_id and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                   "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                    DataSet d2 = OraService.GetDataSet(str_sql, connstr);
                    for (int i = 0; i < d2.Tables[0].Rows.Count; i++)
                    {
                        PSP_interface p = new PSP_interface();
                        //p.UMonth = month.Text;
                        //p.UYear = Convert.ToInt32(year.Text);
                        //if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                        //{
                        //    p.Number = 0;
                        //}
                        //else
                        //{
                        //    p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]);
                        //}
                        if (Convert.IsDBNull(d2.Tables[0].Rows[i][3]))
                        {
                            p.LoadValue = 0;
                        }
                        else
                        {
                            p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]),2));
                        }
                        //p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                        //p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                        //p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                        //p.UID = Guid.NewGuid().ToString();
                        ((PSP_interface)list2[i]).LoadValue = p.LoadValue; ;
                    }

                    ctrlglebeType1.GridControl.DataSource = list2;
                }
                else
                {
                    try
                    {
                        for (int n = 1; n < 13; n++)
                        {
                            string mm = n.ToString();
                            if (mm.Length < 2) { mm = "0" + mm; }
                            StartDate = selYear + "-" + mm + "-01 00:00:00";
                            EndDate = selYear + "-" + mm + "-31 23:59:59";
                            str_sql = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " +
                             "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                             "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                            //con = GetConn();
                            DataSet d = OraService.GetDataSet(str_sql, connstr);
                            for (int i = 0; i < d.Tables[0].Rows.Count; i++)
                            {
                                PSP_interface p = new PSP_interface();
                                p.UMonth = mm;
                                p.UYear = Convert.ToInt32(year.Text);
                                if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                                {
                                    p.Number = 0;
                                }
                                else
                                {
                                    p.Number = Convert.ToDouble(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][3])/10000,2));
                                }

                                if (Convert.IsDBNull(d.Tables[0].Rows[i][4]))
                                {
                                    p.col1 = "0";
                                }
                                else
                                {
                                    p.col1 = Convert.ToString(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][4]) / 10000, 2));
                                }
                                p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                                p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                                p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                                p.UID = Guid.NewGuid().ToString();
                                list2.Add(p);
                            }
                            str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear +mm+ " a,switch b,substation c " +
                           "where b.substation_id=c.id and b.id=a.mp_id  and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate +
                           "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name";
                            //con = GetConn();
                            DataSet d2 = OraService.GetDataSet(str_sql, connstr);
                            for (int i = 0; i < d2.Tables[0].Rows.Count; i++)
                            {
                                PSP_interface p = new PSP_interface();
                                //p.UMonth = mm;
                                //p.UYear = Convert.ToInt32(year.Text);
                                //if (Convert.IsDBNull(d.Tables[0].Rows[i][3]))
                                //{
                                //    p.Number = 0;
                                //}
                                //else
                                //{
                                //    p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]);
                                //}
                                if (Convert.IsDBNull(d2.Tables[0].Rows[i][3]))
                                {
                                    p.LoadValue = 0;
                                }
                                else
                                {
                                    p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]),2));
                                }
                                //p.Substation_Name = d.Tables[0].Rows[i][0].ToString();
                                //p.Switch_Id = d.Tables[0].Rows[i][1].ToString();
                                //p.Switch_Name = d.Tables[0].Rows[i][2].ToString();
                                //p.UID = Guid.NewGuid().ToString();
                                ((PSP_interface)list2[i]).LoadValue=p.LoadValue;
                            }
                        }
                    }
                    catch (Exception ex) {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {

                        ctrlglebeType1.GridControl.DataSource = list2;

                    }
                }
                if (list2.Count > 0) {  }
                else {  }
                frmLoad.Close();
            }
            catch(Exception e1){
                MessageBox.Show("û���ҵ������Ϣ��������ѡ��ʱ�䡣"+e1.Message, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }