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

            if (obj == null)
            {
                return;
            }

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

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

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

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

            obj.UID = Guid.NewGuid().ToString() + "|" + Itop.Client.MIS.ProgUID;
            //执行添加操作
            using (FrmBurdenMonthDialog dlg = new FrmBurdenMonthDialog())
            {
                dlg.TitleName = this.gridView.GroupPanelText;
                dlg.IsCreate  = true;                   //设置新建标志
                dlg.Object    = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

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

            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
        }
Beispiel #3
0
        private void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            Brush     brush = null;
            Rectangle r     = e.Bounds;
            int       year  = 0;
            Color     c1    = Color.FromArgb(255, 121, 121);
            Color     c2    = Color.FromArgb(255, 121, 121);
            object    dr    = this.gridView.GetRow(e.RowHandle);

            if (dr == null)
            {
                return;
            }
            BurdenMonth bl = (BurdenMonth)dr;

            //if (e.Column.FieldName == "BurdenDate")
            //{
            double imax = 0;
            double j    = 0;

            for (int i = 1; i <= 12; i++)
            {
                j = Convert.ToDouble(bl.GetType().GetProperty("Month" + i).GetValue(bl, null));
                if (imax < j)
                {
                    imax = j;
                }
            }
            if (e.Column.FieldName.Contains("Month"))
            {
                if (imax.ToString() == e.CellValue.ToString())
                {
                    brush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, c1, c2, 180);
                    if (brush != null)
                    {
                        e.Graphics.FillRectangle(brush, r);
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            BurdenMonth obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

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

            //执行删除操作
            try
            {
                Services.BaseService.Delete <BurdenMonth>(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 #5
0
        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                DataTable      dts = new DataTable();
                OpenFileDialog op  = new OpenFileDialog();
                op.Filter = "Excel文件(*.xls)|*.xls";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);
                    for (int k = 0; k < dts.Rows.Count; k++)
                    {
                        string year = dts.Rows[k][1].ToString();
                        //string da = dts.Rows[1][1].ToString();
                        //string jj = da.Substring(0, 2);
                        //string day = year + da.Substring(2, da.Length - 2).Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "");

                        BurdenMonth bl = new BurdenMonth();
                        bl.UID        = bl.UID + "|" + Itop.Client.MIS.ProgUID;
                        bl.CreateDate = DateTime.Now;

                        bl.UpdateDate = DateTime.Now;
                        bl.BurdenYear = int.Parse(year);
                        //try
                        //{
                        //    bl. = DateTime.Parse(year);
                        //}
                        //catch
                        //{
                        //    bl.BurdenDate = DateTime.Now;
                        //}
                        string          pjt = " ProjectID='" + MIS.ProgUID + "'and Title='" + dts.Rows[k][0].ToString() + "'";
                        PS_Table_AreaWH lt  = (PS_Table_AreaWH)Common.Services.BaseService.GetObject("SelectPS_Table_AreaWHByConn", pjt);
                        if (lt != null)
                        {
                            bl.AreaID = lt.ID;
                        }

                        bl.Title = "BurdenYear ='" + bl.BurdenYear + "' and  uid like '%" + Itop.Client.MIS.ProgUID + "%' and AreaID='" + bl.AreaID + "'";
                        IList <BurdenMonth> lis = Common.Services.BaseService.GetList <BurdenMonth>("SelectBurdenMonthByWhere", bl.Title);

                        foreach (BurdenMonth bltemp in lis)
                        {
                            bl.UID = bltemp.UID;

                            bl.CreateDate = bltemp.CreateDate;

                            bl.UpdateDate = bltemp.UpdateDate;
                            break;
                        }


                        try{
                            bl.Month1 = double.Parse(dts.Rows[k][2].ToString());
                        }
                        catch { }
                        try{
                            bl.Month2 = double.Parse(dts.Rows[k][3].ToString());
                        }
                        catch { }
                        try{
                            bl.Month3 = double.Parse(dts.Rows[k][4].ToString());
                        }
                        catch { }
                        try{
                            bl.Month4 = double.Parse(dts.Rows[k][5].ToString());
                        }
                        catch { }
                        try{
                            bl.Month5 = double.Parse(dts.Rows[k][6].ToString());
                        }
                        catch { }
                        try{
                            bl.Month6 = double.Parse(dts.Rows[k][7].ToString());
                        }
                        catch { }
                        try{
                            bl.Month7 = double.Parse(dts.Rows[k][8].ToString());
                        }
                        catch { }
                        try{
                            bl.Month8 = double.Parse(dts.Rows[k][9].ToString());
                        }
                        catch { }
                        try{
                            bl.Month9 = double.Parse(dts.Rows[k][10].ToString());
                        }
                        catch { }
                        try{
                            bl.Month10 = double.Parse(dts.Rows[k][11].ToString());
                        }
                        catch { }
                        try{
                            bl.Month11 = double.Parse(dts.Rows[k][12].ToString());
                        }
                        catch { }
                        try{
                            bl.Month12 = double.Parse(dts.Rows[k][13].ToString());
                        }
                        catch { }



                        double minData = 0;
                        double maxData = 0;
                        double sumData = 0;



                        Common.Services.BaseService.Delete <BurdenMonth>(bl);
                        Common.Services.BaseService.Create <BurdenMonth>(bl);
                        ctrlBurdenMonth1.ObjectList.Add(bl);
                    }
                    ctrlBurdenMonth1.RefreshData();
                    UpdataChart();
                    MsgBox.Show("已导入成功!");
                }
            }
            catch { MsgBox.Show("导入格式不正确!"); }
        }
Beispiel #6
0
        //读取数据
        private void LoadValues()
        {
            PSP_ForecastValues psp_Value = new PSP_ForecastValues();

            psp_Value.ForecastID = forecastReport.ID;

            IList <PSP_ForecastValues> listValues = Common.Services.BaseService.GetList <PSP_ForecastValues>("SelectPSP_ForecastValuesByForecastID", psp_Value);

            if (listValues.Count == 0)
            {
                BurdenMonth bm1 = new BurdenMonth();
                bm1.BurdenYear = forecastReport.StartYear;

                BurdenMonth bm = (BurdenMonth)Common.Services.BaseService.GetObject("SelectBurdenMonthByBurdenYear", bm1);
                if (bm != null)
                {
                    //TreeListNode node = treeList1.FindNodeByFieldValue("TypeID", value.TypeID);
                    //if (node != null)
                    //{
                    //    node.SetValue(value.Year + "月", value.Value);
                    //}
                    treeList1.MoveFirst();
                    TreeListNode node = treeList1.FocusedNode;
                    node.SetValue("1月", bm.Month1);
                    node.SetValue("2月", bm.Month2);
                    node.SetValue("3月", bm.Month3);
                    node.SetValue("4月", bm.Month4);
                    node.SetValue("5月", bm.Month5);
                    node.SetValue("6月", bm.Month6);
                    node.SetValue("7月", bm.Month7);
                    node.SetValue("8月", bm.Month8);
                    node.SetValue("9月", bm.Month9);
                    node.SetValue("10月", bm.Month10);
                    node.SetValue("11月", bm.Month11);
                    node.SetValue("12月", bm.Month12);


                    double bmsum = bm.Month1 + bm.Month2 + bm.Month3 + bm.Month4 + bm.Month5 + bm.Month6;
                    bmsum += bm.Month7 + bm.Month8 + bm.Month9 + bm.Month10 + bm.Month11 + bm.Month12;

                    double bmmax = Math.Max(bm.Month1, bm.Month2);
                    bmmax = Math.Max(bmmax, bm.Month3);
                    bmmax = Math.Max(bmmax, bm.Month4);
                    bmmax = Math.Max(bmmax, bm.Month5);
                    bmmax = Math.Max(bmmax, bm.Month6);
                    bmmax = Math.Max(bmmax, bm.Month7);
                    bmmax = Math.Max(bmmax, bm.Month8);
                    bmmax = Math.Max(bmmax, bm.Month9);
                    bmmax = Math.Max(bmmax, bm.Month10);
                    bmmax = Math.Max(bmmax, bm.Month11);
                    bmmax = Math.Max(bmmax, bm.Month12);



                    node.SetValue("13月", bmsum);
                    node.SetValue("14月", bmmax);
                    node.SetValue("15月", bmsum / (bmmax * 12));
                }
            }

            else
            {
                foreach (PSP_ForecastValues value in listValues)
                {
                    TreeListNode node = treeList1.FindNodeByFieldValue("TypeID", value.TypeID);
                    if (node != null)
                    {
                        node.SetValue(value.Year + "月", value.Value);
                    }
                }
            }
        }