Ejemplo n.º 1
0
        protected override void Del()
        {
            if (!DeleteRight)
            {
                MessageBox.Show("您没有此权限。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            PSP_interface ins = new PSP_interface();

            ins.col1 = " BdzId like '%" + treeView1.SelectedNode.Tag.ToString() + "%' ";
            IList <PSP_interface> l2 = Services.BaseService.GetList <PSP_interface>("SelectPSP_interfaceByWhere", ins);

            if (l2.Count > 0)
            {
                MessageBox.Show("分类下包含数据,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (treeView1.SelectedNode.Nodes.Count > 0)
            {
                MessageBox.Show("分类下包含子分类,不能删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show("确定删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                PSP_bdz_type p = new PSP_bdz_type();
                p.id = treeView1.SelectedNode.Tag.ToString();
                Services.BaseService.Update("DeletePSP_bdz_type", p);
                treeView1.Nodes.Remove(treeView1.SelectedNode);
                ctrlLineType1.Typeid = typeid;
                ctrlLineType1.RefreshData();
            }
        }
Ejemplo n.º 2
0
        //public DataSet GetDataSet(string cmd)
        //{
        //    this.CheckConnection();

        //    DataSet dataSet = new DataSet();

        //    try
        //    {
        //        OracleCommand dataCommand = new OracleCommand(cmd, con);
        //        OracleDataAdapter dataAdapter = new OracleDataAdapter();
        //        dataAdapter.SelectCommand = dataCommand;
        //        dataAdapter.Fill(dataSet, "recordSet");

        //    }
        //    catch (Exception se)
        //    {
        //        throw new Exception("Error in SQL", se);
        //    }
        //    finally
        //    {
        //        closeConn();
        //    }
        //    return dataSet;

        //}
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            if (ctrlglebeType1.GridView.GetSelectedRows() == null || ctrlglebeType1.GridView.GetSelectedRows().Length < 1)
            {
                MessageBox.Show("请选择记录。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (Treeid == "")
            {
                MessageBox.Show("请指定一个导入的分类。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //if (lookUpEdit2.Text == "")
            //{
            //    MessageBox.Show("请指定要导入到的分区。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            //if (lookUpEdit3.Text == "")
            //{
            //    MessageBox.Show("请指定要导入到的分系统。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            IList <PSP_interface> list_temp = ctrlglebeType1.GridControl.DataSource as IList <PSP_interface>;

            int[] l = ctrlglebeType1.GridView.GetSelectedRows();

            for (int i = 0; i < l.Length; i++)
            {
                PSP_interface p = ctrlglebeType1.GridView.GetRow(l[i]) as PSP_interface;
                p.BdzId = treeView1.SelectedNode.Tag.ToString();
                //p.FQId = lookUpEdit2.EditValue.ToString();
                //p.FxtId = lookUpEdit3.EditValue.ToString();
                PSP_interface p2 = new PSP_interface();
                p2.col1 = " UYear='" + p.UYear + "' and UMonth='" + p.UMonth + "' and Substation_Name='" + p.Substation_Name + "' and Switch_Id='" + p.Switch_Id + "' ";
                p2      = (PSP_interface)Services.BaseService.GetObject("SelectPSP_interfaceByWhere", p2);
                if (p2 != null)
                {
                    if (!p2.BdzId.Contains(p.BdzId))
                    {
                        p2.BdzId = p2.BdzId + "," + p.BdzId;
                    }
                    //if (!p2.FQId.Contains(p.FQId))
                    //{
                    //    p2.FQId = p2.FQId + "," + p.FQId;
                    //}
                    //if (!p2.FxtId.Contains(p.FxtId))
                    //{
                    //    p2.FxtId = p2.FxtId + "," + p.FxtId;
                    //}
                    Services.BaseService.Update <PSP_interface>(p2);
                }
                else
                {
                    Services.BaseService.Create <PSP_interface>(p);
                }
            }
            MessageBox.Show("导入成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            PSP_interface obj = FocusedObject;

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

            //执行删除操作
            try
            {
                int[] l = gridView.GetSelectedRows();
                for (int i = 0; i < l.Length; i++)
                {
                    PSP_interface p_obj = gridView.GetRow(l[i]) as PSP_interface;
                    PSP_interface p     = new PSP_interface();
                    p.UID = p_obj.UID;
                    p     = (PSP_interface)Services.BaseService.GetObject("SelectPSP_interfaceByKey", p);
                    if (p != null)
                    {
                        p.BdzId = p.BdzId.Replace(typeid, "");
                        if (p.BdzId.Length < 20)
                        {
                            Services.BaseService.Delete <PSP_interface>(p);
                        }
                        else
                        {
                            Services.BaseService.Update <PSP_interface>(p);
                        }
                    }
                }
                this.gridView.BeginUpdate();
                //记住当前焦点行索引
                int iOldHandle = this.gridView.FocusedRowHandle;
                //从链表中删除
                //ObjectList.Remove(p_obj);
                //刷新表格
                gridView.DeleteSelectedRows();
                gridControl.RefreshDataSource();
                //设置新的焦点行索引
                //GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
                this.gridView.EndUpdate();
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }
        }
Ejemplo n.º 4
0
        public void LoadData()
        {
            PSP_interface p = new PSP_interface();

            p = Services.BaseService.GetOneByKey <PSP_interface>(uid);
            if (p != null)
            {
                bdz     = p.BdzId;
                fq      = p.FQId;
                fxt     = p.FxtId;
                bdzlist = bdz.Split(",".ToCharArray());
                fqlist  = fq.Split(",".ToCharArray());
                fxtlist = fxt.Split(",".ToCharArray());
            }
            object[] obj = new object[30];
            for (int i = 0; i < 30; i++)
            {
                obj[i] = 2000 + i;
            }
            this.year.Properties.Items.AddRange(obj);
        }
Ejemplo n.º 5
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            //simpleButton3.Enabled = false;
            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show("请选择分类。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string sql = " 1=1 ";

            if (treeView1.SelectedNode.Tag.ToString() != "0")
            {
                sql = sql + " and BdzId like '%" + treeView1.SelectedNode.Tag.ToString() + "%'";
            }
            //if (lookUpEdit2.Text != "")
            //{
            //    sql = sql + " and FQId like '%" + lookUpEdit2.EditValue + "%'";
            //}
            //if (lookUpEdit3.Text != "")
            //{
            //    sql = sql + " and FxtId like '%" + lookUpEdit3.EditValue + "%'";
            //}
            if (year.Text != "")
            {
                sql = sql + " and UYear=" + year.Text;
            }
            if (month.Text != "全部")
            {
                sql = sql + " and UMonth=" + month.Text;
            }
            sql = sql + " order by UYear,UMonth,Substation_Name,Switch_Id";
            PSP_interface p2 = new PSP_interface();

            p2.col1 = sql;
            IList <PSP_interface> list2 = Services.BaseService.GetList <PSP_interface>("SelectPSP_interfaceByWhere", p2);

            ctrlglebeType1.GridControl.DataSource = list2;
        }
Ejemplo n.º 6
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);
            }
        }