Beispiel #1
0
        public static void CheckHasFixValue(Hashtable ht, DataTable dt, string ForecastID, int type)
        {
            foreach (string  key in ht.Keys)
            {
                bool have = false;
                foreach (DataRow row in dt.Rows)
                {
                    if (key==row["Title"].ToString())
                    {
                        have = true;
                        break;
                    }
                }
                if (!have)
                {
                    try
                    {
                        Ps_Forecast_Math pfm = new Ps_Forecast_Math();
                        pfm.ID = Guid.NewGuid().ToString();
                        pfm.Title = key;
                        pfm.Forecast = type;
                        pfm.ForecastID = ForecastID;
                        object obj = Common.Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null);
                        if (obj != null)
                            pfm.Sort = ((int)obj) + 1;
                        else
                            pfm.Sort = 1;
                        Common.Services.BaseService.Create<Ps_Forecast_Math>(pfm);
                    }
                    catch (Exception)
                    {
                    }

                }
            }
        }
Beispiel #2
0
        private void LoadData()
        {
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                this.treeList1.Columns.Clear();

                //treeList1.Columns.Clear();
            }
            //((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit();
            AddFixColumn();

            for (int i = forecastReport.StartYear; i <= forecastReport.YcEndYear; i++)
            {
                AddColumn(i);
            }
            //((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit();
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            if (listTypes.Count != 3 || ((Ps_Forecast_Math)listTypes[0]).Col1 != "mh")
            {

                try
                {  //删除数据
                    for (int i = 0; i < listTypes.Count; i++)
                    {
                        Common.Services.BaseService.Delete<Ps_Forecast_Math>((Ps_Forecast_Math)listTypes[i]);
                    }
                }
                catch
                {

                }
                List<Ps_Forecast_Math> newlist = new List<Ps_Forecast_Math>() ;
                Ps_Forecast_Math psp_Type1 = new Ps_Forecast_Math();
                psp_Type1.ID = Guid.NewGuid().ToString();
                psp_Type1.ForecastID = forecastReport.ID;
                psp_Type1.Forecast = type;
                psp_Type1.Title = "全社会用电量(亿kWh)";
                psp_Type1.Sort = 1;
                psp_Type1.Col1 = "mh";
                Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type1);
                newlist.Add(psp_Type1);

                Ps_Forecast_Math psp_Type2 = new Ps_Forecast_Math();
                psp_Type2.ID = Guid.NewGuid().ToString();
                psp_Type2.ForecastID = forecastReport.ID;
                psp_Type2.Forecast = type;
                psp_Type2.Title = "全社会最大负荷(MW)";
                psp_Type2.Sort = 2;
                psp_Type2.Col1 = "mh";
                Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type2);
                newlist.Add(psp_Type2);

                Ps_Forecast_Math psp_Type3 = new Ps_Forecast_Math();
                psp_Type3.ID = Guid.NewGuid().ToString();
                psp_Type3.ForecastID = forecastReport.ID;
                psp_Type3.Forecast = type;
                psp_Type3.Title = "最大小时数(时)";
                psp_Type3.Sort = 3;
                psp_Type3.Col1 = "mh";
                Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type3);
                newlist.Add(psp_Type3);

                dataTable = Itop.Common.DataConverter.ToDataTable(newlist);

            }
            else
            {

                dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));
                for (int i = 0; i < listTypes.Count; i++)
                {
                    Ps_Forecast_Math currtenpfm = (Ps_Forecast_Math)listTypes[i];
                    //更新换算单位
                    if (currtenpfm.Sort == 1)
                    {
                        CheckUnit(currtenpfm.Title.ToString());
                    }
                    break;
                }

            }

             this.treeList1.DataSource = dataTable;

            Application.DoEvents();

            bLoadingData = false;
            RefreshChart();
        }
Beispiel #3
0
        /// <summary>
        /// ����Ƚ�
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem29_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //dataTable
            ArrayList a1 = new ArrayList();
            ArrayList a2 = new ArrayList();
            ArrayList a3 = new ArrayList();
            ArrayList a4 = new ArrayList();
            DataTable dt3 = new DataTable();
            dt3.Columns.Add("A", typeof(int));
            dt3.Columns.Add("B",typeof(bool));
            dt3.Columns.Add("C", typeof(bool));
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                DataRow dr = dt3.NewRow();
                dr["A"] = i;
                //dr["B"] = true;
                //dr["C"] = false;
                dt3.Rows.Add(dr);
            }

            FormXuanZhe form = new FormXuanZhe();
            //form.Text = this.Text + "- ����Ƚ�����";
            form.DT2 = dataTable;
            form.DT3 = dt3;
            form.ReportForecastID = forecastReport.ID;
            form.ForecastReport = forecastReport;
            if (form.ShowDialog() != DialogResult.OK)
                return;
            a1 = form.A1;
            a2 = form.A2;
            a3 = form.A3;
            a4 = form.A4;
            DataTable dt = new DataTable();
            foreach (DataColumn dc in dataTable.Columns)
            {
                dt.Columns.Add(dc.ColumnName, dc.DataType);
            }

            IList<Ps_Forecast_Math> li = new List<Ps_Forecast_Math>();
            ArrayList al = new ArrayList();
            foreach (DataRow dr in dataTable.Rows)
            {
                if (!(bool)dr["B"])
                    continue;
                string id = dr["ID"].ToString();
                Ps_Forecast_Math pfvalue = new Ps_Forecast_Math();//ƽ��ֵ
                pfvalue.Title = dr["Title"].ToString() + "<ƽ��ֵ>";
                pfvalue.Title = pfvalue.Title.Replace("�����õ���-", "");
                pfvalue.ID = "999|" + Itop.Client.MIS.ProgUID;
                pfvalue.ForecastID = forecastReport.ID;
                pfvalue.Forecast = Convert.ToInt32(dr["Forecast"]);
                int icount = 0;
                for (int i = 0; i < a1.Count; i++)
                {
                    int m = Convert.ToInt32(a1[i]);

                    Ps_Forecast_Math pf2 = Services.BaseService.GetOneByKey<Ps_Forecast_Math>(id);
                    Ps_Forecast_Math pf1 = new Ps_Forecast_Math();
                    Ps_Forecast_Math pf = new Ps_Forecast_Math();
                    //pf.Col4 = pid;
                    pf.Col1 = id;
                    pf.ForecastID = forecastReport.ID;
                    pf.Forecast = m;
                    IList<Ps_Forecast_Math> li2 = Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByCol1", pf);
                    if (li2.Count == 0)
                    {
                        pf1 = pf2;
                        pf1.Forecast = m;
                        pf1.ID = Guid.NewGuid().ToString();

                    }
                    else
                    {
                        pf1 = li2[0];
                    }
                    string str = "";
                    switch (m)
                    {
                        case 1:
                            str = "�������ʷ�";
                            break;
                        case 2:
                            str = "���Ʒ�";
                            break;
                        case 3:
                            str = "��ط�";
                            break;
                        case 4:
                            str = "����ϵ����";
                            break;
                        case 5:
                            str = "ָ��ƽ����";
                            break;
                        case 6:
                            str = "��ɫģ�ͷ�";
                            break;
                        case 7:
                            str = "ר�Ҿ��߷�";

                            break;
                        case 20:
                            str = "�����㷨";

                            break;
                        case 10:
                            str = "��Ȩ���ϵ����";

                            break;
                        case 11:
                            str = "����������-���û�Ԥ�ⷨ";

                            break;

                    }
                    //if (m != 11)
                    //{
                    //    if ( pf1.Title.Contains("-") && pf1.Title.Contains("����"))
                    //    {
                    //        continue;
                    //    }
                    pf1.Title = pf1.Title + "<" + str + ">";
                    for (int j = forecastReport.StartYear; j <= forecastReport.EndYear; j++)
                    {

                        double value2 = Math.Round(Convert.ToDouble(pfvalue.GetType().GetProperty("y" + j.ToString()).GetValue(pfvalue, null)), 2);
                        double value = Math.Round(Convert.ToDouble(pf1.GetType().GetProperty("y" + j.ToString()).GetValue(pf1, null)), 2);
                        value = Math.Round((value + value2), 2);
                        pfvalue.GetType().GetProperty("y" + j.ToString()).SetValue(pfvalue, value, null);
                    }
                    pf1.Sort = li.Count;
                    icount++;
                    al.Add(pf1.Title);
                    li.Add(pf1);
                }
                //else
                //{
                //    if (pf1.Title.Contains("-")||true)
                //    {
                //         IList<Ps_forecast_list> listReports = Common.Services.BaseService.GetList<Ps_forecast_list>("SelectPs_forecast_listByWhere", "UserID='" + Itop.Client.MIS.ProgUID + "' and Col1='2' and Title='" + forecastReport.Title + "'");
                //         if (listReports.Count > 0)
                //         {
                //             pf1.Title = dr["Title"].ToString();
                //             string[] strtemp = new string [2];
                //             if (pf1.Title.Contains("����"))
                //             {
                //                 strtemp[0] = "����";
                //                 strtemp[1] = pf1.Title;
                //                 if(pf1.Title.Substring(pf1.Title.Length-2,2)=="����")
                //                     strtemp[1] = pf1.Title.Substring(0, pf1.Title.Length - 2);

                //             }
                //             else if (pf1.Title.Contains("����"))
                //             {
                //                 strtemp[0] = "����";
                //                 strtemp[1] = pf1.Title;
                //                 if (pf1.Title.Substring(pf1.Title.Length - 2, 2) == "����")
                //                     strtemp[1] = pf1.Title.Substring(0, pf1.Title.Length - 2);
                //             }

                //             int typetemp = 0;

                //             if (strtemp[0].Contains("����"))
                //                 typetemp = 2;
                //             else
                //                 typetemp = 3;
                //             if (typetemp == 2)
                //             {
                //                 str = "����";
                //             }
                //             else
                //             {
                //                 str = "����";
                //             }
                //             //if (strtemp[1].Contains("ȫ���"))
                //             //{
                //             //    IList<Ps_Forecast_Math> li3 = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByWhere",
                //             //         "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and Title like 'ȫ���%'");

                //             //    foreach (Ps_Forecast_Math ps in li3)
                //             //    {

                //             //        ps.Title = ps.Title + str + "<����������-���û�Ԥ�ⷨ>";

                //             //        if (al.Contains(ps.Title))
                //             //            continue;
                //             //           for (int j = forecastReport.StartYear; j <= forecastReport.EndYear; j++)
                //             //           {

                //             //               double value2 =Math.Round(Convert.ToDouble(pfvalue.GetType().GetProperty("y" + j.ToString()).GetValue(pfvalue, null)),2 );
                //             //               double value = Math.Round(Convert.ToDouble(ps.GetType().GetProperty("y" + j.ToString()).GetValue(ps, null)), 2);
                //             //               value = Math.Round((value + value2) , 2);
                //             //               pfvalue.GetType().GetProperty("y" +j.ToString()).SetValue(pfvalue, value, null);
                //             //           }
                //             //           icount++;
                //             //           ps.Sort = li.Count;

                //             //           al.Add(ps.Title);
                //             //        li.Add(ps);
                //             //    }
                //             //}
                //             //else
                //             {
                //                 object obj = Common.Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere",
                //                         "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and Title='" + strtemp[1] + "'");
                //                 if (obj == null)
                //                     continue;
                //                 pf1 = obj as Ps_Forecast_Math;
                //                 pf1.ParentID = "";
                //                 pf1.Title = pf1.Title + str + "<����������-���û�Ԥ�ⷨ>";

                //                 if (al.Contains(pf1.Title))
                //                     continue;
                //                    for (int j = forecastReport.StartYear; j <= forecastReport.EndYear; j++)
                //                    {

                //                        double value2 =Math.Round(Convert.ToDouble(pfvalue.GetType().GetProperty("y" + j.ToString()).GetValue(pfvalue, null)),2 );
                //                        double value =Math.Round(Convert.ToDouble(pf1.GetType().GetProperty("y" + j.ToString()).GetValue(pf1, null)),2 );
                //                        value = Math.Round((value + value2) , 2);
                //                        pfvalue.GetType().GetProperty("y" + j.ToString()).SetValue(pfvalue, value, null);
                //                    }
                //                    icount++;
                //                    pf1.Sort = li.Count;

                //                                 li.Add(pf1);
                //             }
                //         }
                //    }

                //}

                for (int j = forecastReport.StartYear; j <= forecastReport.EndYear; j++)
                {

                    double value = Math.Round(Convert.ToDouble(pfvalue.GetType().GetProperty("y" + j.ToString()).GetValue(pfvalue, null)), 2);

                    value = Math.Round((value / icount), 2);
                    pfvalue.GetType().GetProperty("y" + j.ToString()).SetValue(pfvalue, value, null);
                }

                li.Add(pfvalue);
            }

            FormForecastJG ffjg = new FormForecastJG();
            ffjg.Text = this.Text + "- ����Ƚ�";
            ffjg.CanEdit = CanEdit;
            ffjg.LI = li;
            ffjg.A1 = a3;
            ffjg.A2 = a4;
            ffjg.PFL = forecastReport;
            ffjg.ShowDialog();
        }
Beispiel #4
0
        private void barButtonItem23_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode row = this.treeList1.FocusedNode;
            if (row == null)
            {
                return;
            }

            string parentid = row["ParentID"].ToString();

            FormTypeTitle frm = new FormTypeTitle();
            frm.TypeTitle = row["Title"].ToString();
            frm.Text = "�޸ķ�����";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
                ForecastClass1.TreeNodeToDataObject(psp_Type, row);

                //psp_Type = Itop.Common.DataConverter.RowToObject<Ps_Forecast_Math>(row);
                psp_Type.Title = frm.TypeTitle;

                try
                {
                    Common.Services.BaseService.Update<Ps_Forecast_Math>(psp_Type);
                    row.SetValue("Title",frm.TypeTitle);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("�޸ij����" + ex.Message);
                }
                RefreshChart();
            }
        }
Beispiel #5
0
        /// <summary>
        /// ��������
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FormForecastLoadData2 ffs = new FormForecastLoadData2();
              //  ffs.Type = type;
            ffs.PID = pid;
            ffs.StartYear = forecastReport.StartYear;
            ffs.EndYear = forecastReport.EndYear;
            if (ffs.ShowDialog() != DialogResult.OK)
                return;

            Hashtable hs = ffs.HS;

            if (hs.Count == 0)
                return;
            string id = Guid.NewGuid().ToString();
            if (New_Flag)
            {
                foreach (Ps_History de3 in hs.Values)
                {
                    Ps_Forecast_Math py = new Ps_Forecast_Math();
                    py.Col1 = de3.ID;
                    py.Forecast = 0;
                    py.ForecastID = forecastReport.ID;

                    py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByCol1", py);
                    if (py == null)
                    {

                        Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math();
                        ForecastMath.Title = de3.Title;

                        for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                        {
                            ForecastMath.GetType().GetProperty("y" + i).SetValue(ForecastMath, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                        }

                        id = id.Substring(0, 8);

                        ForecastMath.Col1 = de3.ID;
                        ForecastMath.ID = id + "|" + de3.ID;
                        ForecastMath.ParentID = id + "|" + de3.ParentID;
                        ForecastMath.Forecast = 0;
                        ForecastMath.ForecastID = forecastReport.ID;
                        ForecastMath.Sort = de3.Sort;
                        Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath);
                    }
                    else
                    {

                        for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                        {
                            py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                        }
                        Services.BaseService.Update<Ps_Forecast_Math>(py);

                    }
                }
            }
            else
            {
                if (ffs.Selectid != "4")
                {
                    foreach (Ps_History de3 in hs.Values)
                    {
                        Ps_Forecast_Math py = new Ps_Forecast_Math();
                        py.Col1 = de3.ID;
                        py.Forecast = 0;
                        py.ForecastID = forecastReport.ID;

                        py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByCol1", py);
                        if (py == null)
                        {

                            Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math();
                            ForecastMath.Title = de3.Title;

                            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                            {
                                ForecastMath.GetType().GetProperty("y" + i).SetValue(ForecastMath, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                            }

                            id = id.Substring(0, 8);

                            ForecastMath.Col1 = de3.ID;
                            ForecastMath.ID = id + "|" + de3.ID;
                            ForecastMath.ParentID = id + "|" + de3.ParentID;
                            ForecastMath.Forecast = 0;
                            ForecastMath.ForecastID = forecastReport.ID;
                            ForecastMath.Sort = de3.Sort;
                            Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath);
                        }
                        else
                        {

                            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                            {
                                py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                            }
                            Services.BaseService.Update<Ps_Forecast_Math>(py);

                        }
                    }

                }
                else if (ffs.Selectid == "4")
                {
                    foreach (PSP_Types de3 in hs.Values)
                    {
                        Ps_Forecast_Math py = new Ps_Forecast_Math();

                        //py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere", "Title='" + de3.Title + "'" + " and Forecast='0' and ForecastID='" + forecastReport.ID + "' and Col1='"+de3.ID+"'");
                        py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere", "  Forecast='0' and ForecastID='" + forecastReport.ID + "' and Col1='" + de3.ID + "'");
                        if (py == null)
                        {

                            Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math();

                            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesByWhere", "TypeID='" + de3.ID + "'");

                            foreach (PSP_Values value in listValues)
                            {

                                ForecastMath.GetType().GetProperty("y" + value.Year).SetValue(ForecastMath, value.Value, null);
                            }

                            id = id.Substring(0, 8);
                            ForecastMath.Title = de3.Title;
                            ForecastMath.Col1 = de3.ID.ToString();
                            ForecastMath.ID = id + "|" + de3.ID;
                            ForecastMath.ParentID = id + "|" + de3.ParentID;
                            ForecastMath.Forecast = 0;
                            ForecastMath.ForecastID = forecastReport.ID;
                            object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null);
                            if (obj != null)
                                ForecastMath.Sort = ((int)obj) + 1;
                            else
                                ForecastMath.Sort = 1;
                            Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath);
                        }
                        else
                        {

                            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesByWhere", " TypeID='" + de3.ID + "'");

                            foreach (PSP_Values value in listValues)
                            {

                                py.GetType().GetProperty("y" + value.Year).SetValue(py, value.Value, null);
                            }

                            Services.BaseService.Update<Ps_Forecast_Math>(py);

                        }
                    }

                }

            }

            LoadData();

            //ArrayList al = M1();
            //for (int i = 0; i < al.Count; i++)
            //{
            //    TreeListNode tlnn = (TreeListNode)al[i];
            //    aaa(tlnn);
            //}

            this.chart_user1.All_Select(true);
            RefreshChart();
        }
Beispiel #6
0
        /*
        private void RefreshChart()
        {

            IList<FORBaseColor> list = Services.BaseService.GetList<FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + typeFlag + "'");

            IList<FORBaseColor> li = new List<FORBaseColor>();
            bool bl = false;
            ArrayList aldatablr = new ArrayList();
            foreach (DataRow row in dataTable.Rows)
            {
                aldatablr.Add(row["ID"].ToString());
            }
            foreach (DataRow row in dataTable.Rows)
            {
                if (aldatablr.Contains(row["ParentID"].ToString()))
                    continue;
                bl = false;
                foreach (FORBaseColor bc in list)
                {
                    if (row["Title"].ToString() == bc.Title && row["ParentID"]!=DBNull.Value)
                    {
                        bl = true;
                        FORBaseColor bc1 = new FORBaseColor();
                        bc1.Color1 = Color.Blue;
                        CopyBaseColor(bc1, bc);
                        li.Add(bc1);
                    }

                }
                if (!bl)
                {
                    FORBaseColor bc1 = new FORBaseColor();
                    bc1.UID = Guid.NewGuid().ToString();
                    bc1.Remark = this.forecastReport.ID.ToString() + "-" + typeFlag;
                    bc1.Title = row["Title"].ToString();
                    bc1.Color = 16711680;
                    bc1.Color1 = Color.Blue;
                    Services.BaseService.Create<FORBaseColor>(bc1);
                    li.Add(bc1);
                }

            }
            ArrayList hs = new ArrayList();
            foreach (FORBaseColor bc2 in li)
            {
                hs.Add(bc2.Color1);
            }

            List<Ps_Forecast_Math> listValues = new List<Ps_Forecast_Math>();

            for (int i = 0; i < treeList1.Nodes.Count; i++)
            {
                TreeListNode row = treeList1.Nodes[i];
                foreach (TreeListColumn col in treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        object obj = row[col.FieldName];
                        if (obj != DBNull.Value)
                        {
                            Ps_Forecast_Math v = new Ps_Forecast_Math();
                            v.ForecastID = forecastReport.ID;
                            v.ID = (string)row["ID"];
                            v.Title = (i + 1).ToString() + "." + row["Title"].ToString();
                            v.Sort = Convert.ToInt32(col.FieldName.Replace("y", ""));
                            v.y1990 = (double)row[col.FieldName];

                            listValues.Add(v);
                        }
                    }
                }

            }

            chart1.Series.Clear();

            ArrayList al = new ArrayList();
            al.Add(Application.StartupPath+"/img/1.ico");
            al.Add(Application.StartupPath + "/img/2.ico");
            al.Add(Application.StartupPath + "/img/3.ico");
            al.Add(Application.StartupPath + "/img/4.ico");
            al.Add(Application.StartupPath + "/img/5.ico");
            al.Add(Application.StartupPath + "/img/6.ico");
            al.Add(Application.StartupPath + "/img/7.ico");
            //al.Add("img/8.ico");
            //al.Add("img/9.ico");
            //al.Add("img/10.ico");

            LegendItem legendItem;
            LegendCell legendCell1;
            LegendCell legendCell2;
            LegendCell legendCell3;
            Legend legend = new Legend();
            legend.AutoFitText = false;

            chart1.DataBindCrossTab(listValues, "Title", "Sort", "y1990", "");
            for (int i = 0; i < chart1.Series.Count; i++)
            {
                legendItem = new Dundas.Charting.WinControl.LegendItem();
                legendCell1 = new Dundas.Charting.WinControl.LegendCell();
                legendCell1.CellType = Dundas.Charting.WinControl.LegendCellType.Image;
                legendCell1.Name = "Cell1";

                legendCell2 = new Dundas.Charting.WinControl.LegendCell();
                legendCell3 = new Dundas.Charting.WinControl.LegendCell();
                legendCell2.CellType = Dundas.Charting.WinControl.LegendCellType.Image;
                legendCell2.Name = "Cell2";
                legendCell3.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
                legendCell3.Name = "Cell3";
                legendCell3.Text = chart1.Series[i].Name;
                legendCell3.TextColor = (Color)hs[i];
                /*Ĭ������״ͼ����������DZ��line
               // chart1.Series[i].Color = (Color)hs[i];
               // chart1.Series[i].Name =chart1.Series[i].Name;
               // chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line;

               // chart1.Series[i].MarkerImage = al[i % 7].ToString();
               // chart1.Series[i].MarkerSize = 7;
               // chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2);

               //// chart1.Series[i].XValueIndexed = true;
                chart1.Series[i].Color = (Color)hs[i];
                chart1.Series[i].Name = (i + 1).ToString() + "." + chart1.Series[i].Name;
                chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line;
                chart1.Series[i].MarkerImage = al[i % 7].ToString();
                chart1.Series[i].MarkerSize = 7;
                chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2);

                chart1.Series[i].ShowInLegend = false;

                legendItem.Cells.Add(legendCell1);
                legendItem.Cells.Add(legendCell3);
                legendItem.Tag = chart1.Series[i];
                if (checkBox1.Checked)
                {
                    legendItem.Cells[0].Image = string.Format(Application.StartupPath + @"/img/chk_checked.png");

                }
                else
                {
                    legendItem.Cells[0].Image = string.Format(Application.StartupPath + @"/img/chk_unchecked.png");
                }
                legend.CustomItems.Add(legendItem);
                chart1.Series[i].Enabled = checkBox1.Checked;
            }

            chart1.ChartAreas["Default"].AxisX.MinorGrid.Enabled = false;
            chart1.ChartAreas["Default"].AxisY.MinorGrid.Enabled = true;
            chart1.ChartAreas["Default"].AxisY.MinorGrid.LineStyle = ChartDashStyle.Dash;
            chart1.ChartAreas["Default"].AxisY.MinorGrid.LineColor = Color.Gray;
            legend.Name = "Default";
            chart1.Legends.Add(legend);

        }
        */
        private void RefreshChart()
        {
            ArrayList ht = new ArrayList();
            ht.Add(Color.Red);
            ht.Add(Color.Blue);
            ht.Add(Color.Green);
            ht.Add(Color.Yellow);
            ht.Add(Color.HotPink);
            ht.Add(Color.LawnGreen);
            ht.Add(Color.Khaki);
            ht.Add(Color.LightSlateGray);
            ht.Add(Color.LightSeaGreen);
            ht.Add(Color.Lime);
            ht.Add(Color.Black);
            ht.Add(Color.Brown);
            ht.Add(Color.Crimson);
            int m = 0;
            IList<FORBaseColor> list = Services.BaseService.GetList<FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + typeFlag + "'");

            IList<FORBaseColor> li = new List<FORBaseColor>();
            bool bl = false;
            ArrayList aldatablr = new ArrayList();
            foreach (DataRow row in dataTable.Rows)
            {
                aldatablr.Add(row["ID"].ToString());
            }
            foreach (DataRow row in dataTable.Rows)
            {
                if (aldatablr.Contains(row["ParentID"].ToString()))
                    continue;
                bl = false;
                foreach (FORBaseColor bc in list)
                {
                    if (row["Title"].ToString() == bc.Title && row["ParentID"] != DBNull.Value)
                    {
                        bl = true;
                        FORBaseColor bc1 = new FORBaseColor();
                        bc1.Color1 = bc.Color1;
                        //bc1.Color1 = Color.Blue;
                        CopyBaseColor(bc1, bc);
                        li.Add(bc1);
                    }

                }
                if (!bl)
                {
                    FORBaseColor bc1 = new FORBaseColor();
                    bc1.UID = Guid.NewGuid().ToString();
                    bc1.Remark = this.forecastReport.ID.ToString() + "-" + typeFlag;
                    bc1.Title = row["Title"].ToString();
                    //bc1.Color = 16711680;
                    if (m == 0)
                    {
                        Random rd = new Random();
                        m = rd.Next(100);
                    }
                    Color cl = (Color)ht[m % 13];
                    bc1.Color = ColorTranslator.ToOle(cl);
                    bc1.Color1 =cl;
                    //bc1.Color1 = Color.Blue;
                    Services.BaseService.Create<FORBaseColor>(bc1);
                    li.Add(bc1);
                }
                m++;
            }
            ArrayList hs = new ArrayList();
            foreach (FORBaseColor bc2 in li)
            {
                hs.Add(bc2.Color1);
            }

            List<Ps_Forecast_Math> listValues = new List<Ps_Forecast_Math>();

            for (int i = 0; i < treeList1.Nodes.Count; i++)
            {
                TreeListNode row = treeList1.Nodes[i];
                foreach (TreeListColumn col in treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        object obj = row[col.FieldName];
                        if (obj != DBNull.Value)
                        {
                            Ps_Forecast_Math v = new Ps_Forecast_Math();
                            v.ForecastID = forecastReport.ID;
                            v.ID = (string)row["ID"];
                            v.Title =  row["Title"].ToString();
                            v.Sort = Convert.ToInt32(col.FieldName.Replace("y", ""));
                            v.y1990 = (double)row[col.FieldName];

                            listValues.Add(v);
                        }
                    }
                }

            }

            this.chart_user1.RefreshChart(listValues, "Title", "Sort", "y1990", hs);
        }
Beispiel #7
0
        private void InitMenu()
        {
            barButtonItem1.ImageIndex = -1;
            barButtonItem25.ImageIndex = -1;
            barButtonItem3.ImageIndex = -1;
            barButtonItem2.ImageIndex = -1;
            barButtonItem8.ImageIndex = -1;
            barButtonItem4.ImageIndex = -1;
            barButtonItem19.ImageIndex = -1;
            //barButtonItem12.ImageIndex = -1;
            //barButtonItem16.ImageIndex = -1;
            //barButtonItem19.ImageIndex = -1;
            barButtonItem30.ImageIndex = -1;

            Ps_Forecast_Math psp_Typen = new Ps_Forecast_Math();
            psp_Typen.ForecastID = forecastReport.ID;
            psp_Typen.Forecast = 1;
            IList listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem1.ImageIndex = 0;

            psp_Typen.Forecast = 2;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem25.ImageIndex = 0;

            psp_Typen.Forecast = 3;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem3.ImageIndex = 0;

            psp_Typen.Forecast = 4;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem2.ImageIndex = 0;

            psp_Typen.Forecast = 5;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem8.ImageIndex = 0;

            psp_Typen.Forecast = 6;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem4.ImageIndex = 0;

            psp_Typen.Forecast = 7;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem19.ImageIndex = 0;
            psp_Typen.Forecast = 12;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem30.ImageIndex = 0;
            psp_Typen.Forecast = 17;
            listTypesn = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Typen);
            if (listTypesn.Count > 0)
                barButtonItem35.ImageIndex = 0;
        }
        private void LoadData()
        {
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable2 != null)
            {
                dataTable1.Columns.Clear();
                dataTable2.Columns.Clear();
                treeList2.Columns.Clear();
                treeList1.Columns.Clear();

            }
            if (dataTable2 != null)
            {
                treeList3.Columns.Clear();
            }
            if (dataTable1 != null)
            {
                dataTable1.Columns.Clear();
            }
            AddFixColumn();
            AddFixColumn2();
            AddFixColumn3();
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn(i);
            }
            for (int i = forecastReport.StartYear; i <=forecastReport.EndYear; i++)
            {
                AddColumn2(i);
            }
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn3(i);
            }

            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList<Ps_Forecast_Math> listTypes = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_Forecast_Math));
            treeList2.DataSource = dataTable2;

            Hashtable ht = new Hashtable();
            IList<Ps_BadData> list = new List<Ps_BadData>();
            foreach (Ps_Forecast_Math pfm in listTypes)
            {
                Ps_BadData pb1 = new Ps_BadData();
                pb1.ForecastID = pfm.ForecastID;
                pb1.Forecast = type;
                pb1.Col1 = pfm.ID;
                Ps_BadData pb = new Ps_BadData();
                IList<Ps_BadData> li = Common.Services.BaseService.GetList<Ps_BadData>("SelectPs_BadDataByCol1", pb1);
                if (li.Count == 0)
                {
                    pb = new Ps_BadData();
                    pb.ID = pfm.ID+"|m|"+type;
                    pb.Title = pfm.Title;
                    pb.ForecastID = pfm.ForecastID;
                    pb.Forecast = type;
                    pb.Col1 = pfm.ID;
                    pb.ParentID = pfm.ParentID + "|m|" + type;
                    Services.BaseService.Create<Ps_BadData>(pb);
                }
                else
                    pb = li[0];
                list.Add(pb);
            }
            dataTable1 = Itop.Common.DataConverter.ToDataTable((IList)list, typeof(Ps_BadData));

            treeList2.Columns["Title"].OptionsColumn.AllowEdit = false;
            treeList1.DataSource = dataTable1;
            Application.DoEvents();
            bLoadingData = false;
        }
Beispiel #9
0
        private void LoadData()
        {
            this.splitContainerControl1.SplitterPosition = (2 * this.splitterControl1.Width) / 3;
            this.splitContainerControl2.SplitterPosition = splitContainerControl2.Height / 2;
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                treeList1.Columns.Clear();
            }
            AddFixColumn();
            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn(i);
            }
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));

            treeList1.DataSource = dataTable;

            treeList1.Columns["Title"].OptionsColumn.AllowEdit = false;
            Ps_Calc pcs = new Ps_Calc();
            pcs.Forecast = 5;
            pcs.ForecastID = forecastReport.ID;
            IList<Ps_Calc> list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs);
            if (list1.Count > 0)
            {

                spinEdit1.Value = (decimal)list1[0].Value1;

            }
            Application.DoEvents();
            bLoadingData = false;
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem==null)
            {
                return;
            }
            if (comboBox1.SelectedItem.ToString() == "���Ʒ�")
            {
                if (!comboBox6.Items.Contains("���Ʒ�(�������ʷ�)"))
                {
                    comboBox6.Items.Clear();
                    comboBox6.Items.Add("���Ʒ�(�������ʷ�)");
                    comboBox6.Items.Add("���Ʒ�(ֱ��)");
                    comboBox6.Items.Add("���Ʒ�(������)");
                    comboBox6.Items.Add("���Ʒ�(����)");
                    comboBox6.Items.Add("���Ʒ�(ָ��)");
                    comboBox6.Items.Add("���Ʒ�(��������)");

                }

                comboBox6.Visible = true;
                comboBox6.Enabled = true;
                label6.Visible = true;
                label6.Enabled = true;

            }
            else if (comboBox1.SelectedItem.ToString() == "��ط�")
            {
                if (!comboBox6.Items.Contains("��ط�(ֱ��)"))
                {
                    comboBox6.Items.Clear();
                    comboBox6.Items.Add("��ط�(ֱ��)");
                    comboBox6.Items.Add("��ط�(������)");
                    comboBox6.Items.Add("��ط�(����)");
                    comboBox6.Items.Add("��ط�(ָ��)");
                    comboBox6.Items.Add("��ط�(��������)");

                }

                comboBox6.Visible = true;
                comboBox6.Enabled = true;
                label6.Visible = true;
                label6.Enabled = true;

            }
            else if (comboBox1.SelectedItem.ToString() == "ָ��ƽ����")
            {
                    Ps_Calc pcs = new Ps_Calc();
                    pcs.Forecast = 5;
                    pcs.ForecastID = forecastReport.ID;
                    IList<Ps_Calc> list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs);
                    if (list1.Count < 1)
                    {
                        MessageBox.Show("ƽ������δ���ã�����Ĭ��ֵ0.1����");
                    }
                    comboBox6.Visible = false;
                    comboBox6.Enabled = false;
                    label6.Visible = false;
                    label6.Enabled = false;

            }
            else if (comboBox1.SelectedItem.ToString() == "ר�Ҿ��߷�")
            {
                 Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
                psp_Type.ForecastID = forecastReport.ID;
                psp_Type.Forecast = 7;
                IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);
                if (listTypes.Count<1)
                {
                    MessageBox.Show("ר�Ҿ��߷�û�����ݣ�ѡ��ʧ��");
                    comboBox1.SelectedIndex = -1;
                }
            }

            else
            {
                comboBox6.Visible = false;
                comboBox6.Enabled = false;
                label6.Visible = false;
                label6.Enabled = false;
            }
        }
        private void FormForecastCalc4_Load(object sender, EventArgs e)
        {
            #region ������չʵ��

            Ps_YearRange py = new Ps_YearRange();
            py.Col4 = "������չʵ������";
            py.Col5 = Itop.Client.MIS.ProgUID;

            IList<Ps_YearRange> li2 = Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py);
            if (li2.Count > 0)
            {
                firstyear1 = li2[0].StartYear;
                endyear1 = li2[0].FinishYear;
            }
            //�¾�������
            //Ps_History psp_Type = new Ps_History();
            //psp_Type.Forecast = 5;
            //psp_Type.Col4 = Itop.Client.MIS.ProgUID;
            //IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type);
            //DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History));
            //DataRow[] rows1 = dataTable.Select("Title like 'ȫ����GDP%'");

            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));
            DataRow[] rows1 = dataTable.Select("Title like 'ȫ����GDP%'");

            DataRow[] rows4 = dataTable.Select("Title like 'ȫ����õ���%'");

            //�µ�������
            //Ps_History psp_Type2 = new Ps_History();
            //psp_Type2.Forecast = 6;
            //psp_Type2.Col4 = Itop.Client.MIS.ProgUID;
            //IList<Ps_History> listTypes2 = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type2);
            //DataTable dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes2, typeof(Ps_History));
            //DataRow[] rows4 = dataTable2.Select("Title like 'ȫ����õ���%'");

            if (rows1.Length == 0 )
            {
                MessageBox.Show("ȱ�١�ȫ����GDP�����ݣ�");
                this.Close();
                return;
            }

            if (rows4.Length==0)
            {
                MessageBox.Show("����������ȱ�١�ȫ����õ��������ݣ�");
                this.Close();
                return;
            }

            #endregion

            Ps_Forecast_Setup pfs = new Ps_Forecast_Setup();
            pfs.Forecast = type;
            pfs.ForecastID = forecastReport.ID;

            IList<Ps_Forecast_Setup> li = Services.BaseService.GetList<Ps_Forecast_Setup>("SelectPs_Forecast_SetupByForecast", pfs);

            if (li.Count != 0)
            {
                firstyear = li[0].StartYear;
                endyear = li[0].EndYear;
            }

            Ps_Calc pcs = new Ps_Calc();
            pcs.Forecast = type;
            pcs.ForecastID = forecastReport.ID;
            list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs);

            HideToolBarButton();

            dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Name");

            newrow1 = dt.NewRow();
            newrow1["ID"] = "ID";
            newrow1["Name"] = "����ϵ��";
            //newrow2 = dt.NewRow();
            //newrow2["Name"] = "GDP������";

            for (int i = firstyear; i <= forecastReport.YcEndYear; i++)
            {
                dt.Columns.Add(i.ToString(), typeof(double));
                DevExpress.XtraVerticalGrid.Rows.EditorRow editorRow = new DevExpress.XtraVerticalGrid.Rows.EditorRow();
                editorRow.Properties.FieldName = i.ToString().Trim();
                editorRow.Properties.Caption =i.ToString().Trim();
                editorRow.Height = 20;
                editorRow.Properties.RowEdit = this.repositoryItemCalcEdit4;
                this.vGridControl2.Rows.AddRange(new DevExpress.XtraVerticalGrid.Rows.BaseRow[] { editorRow });

                double s1 = 0;
                double s2 = 0;
                double s3 = 0;
                double s4 = 0;
                double s5 = 0;
                double s6 = 0;
                double s7 = 0;
                try { s1 = Convert.ToDouble(rows1[0]["y" + i]); }
                catch { }
                try { s2 = Convert.ToDouble(rows1[0]["y" + (i-1)]); }
                catch { }

                try { s3 = Convert.ToDouble(rows4[0]["y" + i]); }
                catch { }
                try { s4 = Convert.ToDouble(rows4[0]["y" + (i - 1)]); }
                catch { }

                if (s2 != 0)
                    s5 = (s1 - s2) / s2;

                if (s4 != 0)
                    s6 = (s3 - s4) / s4;

                if (s5 != 0)
                    s7 = s6 / s5;

                newrow1[i.ToString()] = Math.Round(s7,3);
                //newrow2[i.ToString()] =Math.Round( s5,3);

                if (i>=forecastReport.YcStartYear)
                {
                    foreach (Ps_Calc pcs2 in list1)
                    {
                        if (i == pcs2.Year)
                        {
                            newrow1[i.ToString()] = Math.Round(pcs2.Value1, 3);
                        }
                    }

                }

            }
            dt.Rows.Add(newrow1);
            //dt.Rows.Add(newrow2);
             //       gridControl1.DataSource = dt;

            vGridControl2.DataSource = dt;
        }
        private void LoadData()
        {
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                this.treeList1.Columns.Clear();

            }
            AddFixColumn();

            for (int i = forecastReport.StartYear; i <= forecastReport.YcEndYear; i++)
            {
                AddColumn(i);
            }
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));

            this.treeList1.DataSource = dataTable;

            Application.DoEvents();

            bLoadingData = false;
            this.chart_user1.All_Select(true);
            RefreshChart();
        }
        private void GetResult()
        {
            string sql = " Col4='yes' and (Forecast=1 or Forecast=2  or Forecast=5 or Forecast=6 or Forecast=7 or Forecast=13 or Forecast=15 or Forecast=20) and ParentID=''";
            sql += "  and ForecastID='" + forecastReport.ID + "'";

            htable.Clear();

            IList<Ps_Forecast_Math> list = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByWhere",sql);
            foreach (Ps_Forecast_Math pfm in list)
            {
                if (!htable.ContainsKey(pfm.Title))
                {
                    htable.Add(pfm.Title, pfm.Title);
                }
            }
            foreach (string key in htable.Keys)
            {
                resulttable.Clear();
                Ps_Forecast_Math pfm = new Ps_Forecast_Math();
                pfm.ID = Guid.NewGuid().ToString();
                pfm.Title = key.ToString()+"-推荐值";
                pfm.Forecast = type;
                pfm.ForecastID = forecastReport.ID;
                Common.Services.BaseService.Create<Ps_Forecast_Math>(pfm);

                string sqlr = " Col4='yes' and (Forecast=1 or Forecast=2  or Forecast=5 or Forecast=6 or Forecast=7 or Forecast=13 or Forecast=15 or Forecast=20) and ParentID=''";
                sqlr += "  and ForecastID='" + forecastReport.ID + "'  and Title='" + key.ToString() + "'";
                IList<Ps_Forecast_Math> listresult = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByWhere", sqlr);
                foreach (Ps_Forecast_Math pfmr in listresult)
                {
                    string title = string.Empty;
                    if (GetMetheod(pfmr.Forecast, out title))
                    {
                        pfmr.ID = Guid.NewGuid().ToString();
                        pfmr.Forecast = type;
                        pfmr.Title = title;
                        pfmr.ParentID = pfm.ID;
                        pfmr.Col2 = "0";
                        pfmr.Col4 = "";
                        Common.Services.BaseService.Create<Ps_Forecast_Math>(pfmr);
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// ��Ӧ���û�����
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            IList<Ps_forecast_list> listReports = Common.Services.BaseService.GetList<Ps_forecast_list>("SelectPs_forecast_listByWhere", "UserID='" + Itop.Client.MIS.ProgUID + "' and Col1='2' and Title='" + forecastReport.Title + "'");
            if (listReports.Count > 0)
            {
                WaitDialogForm wait = new WaitDialogForm("", "���ڸ�������, ���Ժ�...");
                DataRow[] drlist = dataTable.Select("Title like '%-%'");
                int typetemp = 0;
                foreach (DataRow dr in drlist)
                {
                    Ps_Forecast_Math psp_TypePan = new Ps_Forecast_Math();
                    string[] str = dr["Title"].ToString().Split('-');
                    if (str[0].Contains("����"))
                        typetemp = 2;
                    else
                        typetemp = 3;
                    //psp_Type.Forecast = 2;
                    //psp_Type.ForecastID = listReports[0].ID;
                    //psp_Type.Title=str[1];
                    object obj = Common.Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere",
                        "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and Title='" + str[1] + "'");
                    if (obj == null)
                        continue;
                    Ps_Forecast_Math psp_Type = obj as Ps_Forecast_Math;
                    psp_TypePan = obj as Ps_Forecast_Math;
                    obj = Common.Services.BaseService.GetObject("SelectPs_Forecast_MathByWhere",
                        "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and ParentID='" + psp_Type.ID + "'" + " and Title='" + str[0] + "'");
                    if (obj == null)
                        continue;
                     psp_Type = obj as Ps_Forecast_Math;
                    Ps_Forecast_Math v = DataConverter.RowToObject<Ps_Forecast_Math>(dr);
                    v.ID = psp_Type.ID;
                    v.ParentID = psp_Type.ParentID;
                    v.Forecast = psp_Type.Forecast;
                    v.ForecastID = psp_Type.ForecastID;
                    v.Sort = psp_Type.Sort;
                    v.Title = psp_Type.Title;
                    v.Col1 = psp_Type.Col1;
                    v.Col2 = psp_Type.Col2;
                    v.Col3 = psp_Type.Col3;
                    v.Col4 = psp_Type.Col4;
                    Common.Services.BaseService.Update<Ps_Forecast_Math>(v);

                    updateAllPan(psp_TypePan,   listReports[0]);
                    //////////////����
                    //string strtemp = "";
                    //if (typetemp==2)
                    //{
                    //   strtemp = " and Title!='ͬʱ��'";
                    //}
                    //else
                    //    if (typetemp == 3)
                    //    {
                    //        strtemp = "";
                    //    }
                    //IList<Ps_Forecast_Math> mathlist = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByWhere",
                    //   "Forecast='" + typetemp + "' and ForecastID='" + listReports[0].ID + "' and ParentID='" + psp_TypePan.ID + "'" + strtemp);
                    //double value = 0;
                    //for (int i = listReports[0].StartYear; i < listReports[0].EndYear; i++)
                    //{
                    //    value = 0;
                    //    foreach (Ps_Forecast_Math mat in mathlist)
                    //    {
                    //        if (mat.Title=="ͬʱ��")
                    //        value*= (double)mat.GetType().GetProperty("y" + i.ToString()).GetValue(mat, null);
                    //        else
                    //        value += (double)mat.GetType().GetProperty("y" + i.ToString()).GetValue(mat, null);

                    //    }
                    //    psp_TypePan.GetType().GetProperty("y" + i.ToString()).SetValue(psp_TypePan, value, null);
                    //    Common.Services.BaseService.Update<Ps_Forecast_Math>(psp_TypePan);
                    //}
                }
                wait.Close();
                MessageBox.Show("���³ɹ���");
            }
        }
Beispiel #15
0
        private void updateAllPan(Ps_Forecast_Math psp_TypePan, Ps_forecast_list listReports)
        {
            string strtemp = "";
            if (psp_TypePan.Forecast == 2)
            {
                strtemp = " and Title!='ͬʱ��'";
            }
            else
                if (psp_TypePan.Forecast == 3)
                {
                    strtemp = "";
                }
            IList<Ps_Forecast_Math> mathlist = Common.Services.BaseService.GetList<Ps_Forecast_Math>("SelectPs_Forecast_MathByWhere",
                          "Forecast='" + psp_TypePan.Forecast + "' and ForecastID='" + psp_TypePan.ForecastID + "' and ParentID='" + psp_TypePan.ID + "'" + strtemp+" order by sort desc");
            Ps_Forecast_Math matcgui ;
            Ps_Forecast_Math matdyh;
            Ps_Forecast_Math mattsl;

            //if (psp_TypePan.Title.Contains("���غϼ�"))
            //{
                matcgui = new Ps_Forecast_Math();//����
                matdyh = new Ps_Forecast_Math();//���û�
                mattsl = new Ps_Forecast_Math();//ͬʱ��
            //}
            double value = 0;
            double value2 = 0;
            for (int i = listReports.StartYear; i <= listReports.EndYear; i++)
            {
                value = 0;
                 value2 = 0;
                foreach (Ps_Forecast_Math mat in mathlist)
                {
                    if (psp_TypePan.Title.Contains("���غϼ�") && (mat.Title.Contains("����") || mat.Title.Contains("���û�") || mat.Title.Contains("ͬʱ��")))
                    {
                        if (mat.Title.Contains("����"))
                        {
                            matcgui = mat;
                        }
                        else
                        if (mat.Title.Contains("���û�"))
                        {
                            matdyh = mat;
                        }
                        else
                            if (mat.Title.Contains("ͬʱ��"))
                            {
                                mattsl = mat;
                            }
                    if (!mat.Title.Contains("ͬʱ��"))
                        continue;
                    }
                    if (mat.Title == "ͬʱ��")
                        value2 = value2 * Math.Round(Convert.ToDouble( mat.GetType().GetProperty("y" + i.ToString()).GetValue(mat, null)),2);
                    else
                        value2 += Math.Round(Convert.ToDouble(mat.GetType().GetProperty("y" + i.ToString()).GetValue(mat, null)), 2);

                }
                value += value2;
                psp_TypePan.GetType().GetProperty("y" + i.ToString()).SetValue(psp_TypePan, value, null);
                Common.Services.BaseService.Update<Ps_Forecast_Math>(psp_TypePan);
            }
            if (psp_TypePan.ParentID != "")
            {
                psp_TypePan = Common.Services.BaseService.GetOneByKey<Ps_Forecast_Math>(psp_TypePan.ParentID);
                updateAllPan(psp_TypePan, listReports);
            }
            else
                if (psp_TypePan.Title.Contains("���غϼ�"))
                {
                    value = 0;
                    value2 = 0;
                    for (int i = listReports.StartYear; i <= listReports.EndYear; i++)
                    {
                        value2 =  Math.Round(Convert.ToDouble(mattsl.GetType().GetProperty("y" + i.ToString()).GetValue(mattsl, null)),2);
                        if ( psp_TypePan.Forecast==3)
                        {
                            if(value2 != 0 )
                            {
                            value2=Math.Round(Convert.ToDouble(psp_TypePan.GetType().GetProperty("y" + i.ToString()).GetValue(psp_TypePan, null)),2)/value2;

                             value=value2-Math.Round(Convert.ToDouble(matdyh.GetType().GetProperty("y" + i.ToString()).GetValue(matdyh, null)),2);
                            matcgui.GetType().GetProperty("y" + i.ToString()).SetValue(matcgui, value, null);
                                 Common.Services.BaseService.Update<Ps_Forecast_Math>(matcgui);
                            }

                        }
                        else
                            if (psp_TypePan.Forecast == 2)
                            {
                                value2 =Math.Round(Convert.ToDouble(psp_TypePan.GetType().GetProperty("y" + i.ToString()).GetValue(psp_TypePan, null)),2 );
                                value = value2 -Math.Round( Convert.ToDouble(matdyh.GetType().GetProperty("y" + i.ToString()).GetValue(matdyh, null)),2);
                                matcgui.GetType().GetProperty("y" + i.ToString()).SetValue(matcgui, value, null);
                                Common.Services.BaseService.Update<Ps_Forecast_Math>(matcgui);

                            }

                    }

                }
        }
        private void SelectData()
        {
            object row = this.gridView1.GetRow(this.gridView1.FocusedRowHandle);
            if (row == null)
                return;

            Ps_forecast_list pf = row as Ps_forecast_list;

            string id = pf.ID;
            int m = 1;
            switch (barEditItem1.EditValue.ToString())
            {
                case "�������ʷ�":
                    m = 1;
                    break;
                case "���Ʒ�":
                    m = 2;
                    break;
                case "ָ��ƽ����":
                    m = 3;
                    break;
                case "����ϵ����":
                    m = 4;
                    break;
                case "��ֵ���ķ�":
                    m = 17;
                    break;
                case "��ɫ���۷�":
                    m = 6;
                    break;
                case "ר�Ҿ��߷�":
                    m = 7;
                    break;
                case "�����㷨":
                    m = 9;
                    break;
                case "�Ƽ�ֵ":
                    m = 30;
                    break;

            }
            DataTable dataTable = new DataTable();

            bool bLoadingData = true;
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                this.gridView2.Columns.Clear();
            }
            AddFixColumn();

            for (int i = pf.StartYear; i <= pf.YcEndYear; i++)
            {
                AddColumn(i);
            }
            if (m == 30)
            {
                string sql2 = " Col4='yes' and Forecast=" + m + " and ParentID='' and ForecastID='" + id + "'";
                IList list = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByWhere", sql2);
                dataTable = Itop.Common.DataConverter.ToDataTable(list, typeof(Ps_Forecast_Math));
            }
            else
            {
                Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
                psp_Type.ForecastID = id;
                psp_Type.Forecast = m;
                IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

                dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));
            }

            this.gridControl2.DataSource = dataTable;

            Application.DoEvents();
            bLoadingData = false;
        }
        private void barButtonItem1_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            Common.Services.BaseService.Update("DeletePs_Forecast_MathForecastIDAndForecast", psp_Type);
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);
            foreach (Ps_Forecast_Math psp_Typetemp in listTypes)
            {
                psp_Type = new Ps_Forecast_Math();
                psp_Type = psp_Typetemp;
                psp_Type.ID = Guid.NewGuid().ToString();
                psp_Type.Forecast = type;
                Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type);
            }

            LoadData();

            RefreshChart();
        }
Beispiel #18
0
        private void RefreshChart(int syear, int eyear)
        {
            IList<FORBaseColor> list = Services.BaseService.GetList<FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + type + "'");

            IList<FORBaseColor> li = new List<FORBaseColor>();
            bool bl = false;
            foreach (DataRow row in dataTable.Rows)
            {
                bl = false;
                foreach (FORBaseColor bc in list)
                {
                    if (row["Title"].ToString() == bc.Title)
                    {
                        bl = true;
                        FORBaseColor bc1 = new FORBaseColor();
                        bc1.Color1 = Color.Blue;
                        CopyBaseColor(bc1, bc);
                        li.Add(bc1);
                    }

                }
                if (!bl)
                {
                    FORBaseColor bc1 = new FORBaseColor();
                    bc1.UID = Guid.NewGuid().ToString();
                    bc1.Remark = this.forecastReport.ID.ToString() + "-" + type;
                    bc1.Title = row["Title"].ToString();
                    bc1.Color = 16711680;
                    bc1.Color1 = Color.Blue;
                    Services.BaseService.Create<FORBaseColor>(bc1);
                    li.Add(bc1);
                }

            }
            ArrayList hs = new ArrayList();
            foreach (FORBaseColor bc2 in li)
            {
                hs.Add(bc2.Color1);
            }

            List<Ps_Forecast_Math> listValues = new List<Ps_Forecast_Math>();

            for (int i = 0; i < this.treeList1.Nodes.Count; i++)
            {
                TreeListNode row = treeList1.Nodes[i];
                foreach (TreeListColumn col in treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        int yyear = int.Parse(col.FieldName.Replace("y", ""));
                        if (yyear >= syear && yyear <= eyear)
                        {
                            object obj = row[col.FieldName];
                            if (obj != DBNull.Value)
                            {
                                Ps_Forecast_Math v = new Ps_Forecast_Math();
                                v.ForecastID = forecastReport.ID;
                                v.ID = (string)row["ID"];
                                v.Title = row["Title"].ToString();
                                v.Sort = Convert.ToInt32(col.FieldName.Replace("y", ""));
                                v.y1990 = (double)row[col.FieldName];

                                listValues.Add(v);
                            }
                        }
                    }
                }

            }

            chart1.Series.Clear();

            chart1.DataBindCrossTab(listValues, "Title", "Sort", "y1990", "");
            //for (int i = 0; i < chart1.Series.Count; i++)
            //{
            //    chart1.Series[i].Color = (Color)hs[i];
            //    chart1.Series[i].Name = (i + 1).ToString() + "." + chart1.Series[i].Name;
            //    chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line;

            //    chart1.Series[i].MarkerSize = 7;
            //    chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2);

            //}
            m_pf.SetChart(chart1, checkBox1, hs, null);
        }
        private void RefreshChart()
        {
            IList<FORBaseColor> list = Services.BaseService.GetList<FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-1" + type + "'");

            IList<FORBaseColor> li = new List<FORBaseColor>();
            bool bl = false;
            foreach (DataRow row in dataTable2.Rows)
            {
                bl = false;
                foreach (FORBaseColor bc in list)
                {
                    if (row["Title"].ToString() == bc.Title)
                    {
                        bl = true;
                        FORBaseColor bc1 = new FORBaseColor();
                        bc1.Color1 = Color.Blue;
                        CopyBaseColor(bc1, bc);
                        li.Add(bc1);
                    }

                }
                if (!bl)
                {
                    FORBaseColor bc1 = new FORBaseColor();
                    bc1.UID = Guid.NewGuid().ToString();
                    bc1.Remark = this.forecastReport.ID.ToString() + "-1" + type;
                    bc1.Title = row["Title"].ToString();
                    bc1.Color = 16711680;
                    bc1.Color1 = Color.Blue;
                    Services.BaseService.Create<FORBaseColor>(bc1);
                    li.Add(bc1);
                }

            }
            ArrayList hs = new ArrayList();
            foreach (FORBaseColor bc2 in li)
            {
                hs.Add(bc2.Color1);
            }

            List<Ps_Forecast_Math> listValues = new List<Ps_Forecast_Math>();

            for (int i = 0; i < treeList2.Nodes.Count; i++)
            {
                TreeListNode row = treeList2.Nodes[i];

                TreeListNode row1 = treeList1.Nodes[i];
                foreach (TreeListColumn col in treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        object obj = row[col.FieldName];
                        if (obj != DBNull.Value)
                        {
                            Ps_Forecast_Math v = new Ps_Forecast_Math();
                            v.ForecastID = forecastReport.ID;
                            v.ID = (string)row["ID"];
                            v.Title = (i + 1).ToString() + "." + row["Title"].ToString();
                            v.Sort = Convert.ToInt32(col.FieldName.Replace("y", ""));
                            v.y1990 = (double)row[col.FieldName]+(double)row1[col.FieldName];

                            listValues.Add(v);
                        }
                    }
                }

            }

            chart1.Series.Clear();
            ArrayList al = new ArrayList();
            al.Add(Application.StartupPath + "/img/1.ico");
            al.Add(Application.StartupPath + "/img/2.ico");
            al.Add(Application.StartupPath + "/img/3.ico");
            al.Add(Application.StartupPath + "/img/4.ico");
            al.Add(Application.StartupPath + "/img/5.ico");
            al.Add(Application.StartupPath + "/img/6.ico");
            al.Add(Application.StartupPath + "/img/7.ico");

            chart1.DataBindCrossTab(listValues, "Title", "Sort", "y1990", "");
            for (int i = 0; i < chart1.Series.Count; i++)
            {
                chart1.Series[i].Color = (Color)hs[i];
                chart1.Series[i].Name = chart1.Series[i].Name;
                chart1.Series[i].Type = Dundas.Charting.WinControl.SeriesChartType.Line;
                chart1.Series[i].MarkerImage = al[i % 7].ToString();
                chart1.Series[i].MarkerSize = 7;
                chart1.Series[i].MarkerStyle = (Dundas.Charting.WinControl.MarkerStyle)(2);

            }
        }
Beispiel #20
0
        private void RefreshChart(int syear, int eyear)
        {
            IList<FORBaseColor> list = Services.BaseService.GetList<FORBaseColor>("SelectFORBaseColorByWhere", "Remark='" + this.forecastReport.ID.ToString() + "-" + type + "'");

            IList<FORBaseColor> li = new List<FORBaseColor>();
            bool bl = false;
            foreach (DataRow row in dataTable.Rows)
            {
                bl = false;
                foreach (FORBaseColor bc in list)
                {
                    if (row["Title"].ToString() == bc.Title)
                    {
                        bl = true;
                        FORBaseColor bc1 = new FORBaseColor();
                        bc1.Color1 = Color.Blue;
                        CopyBaseColor(bc1, bc);
                        li.Add(bc1);
                    }

                }
                if (!bl)
                {
                    FORBaseColor bc1 = new FORBaseColor();
                    bc1.UID = Guid.NewGuid().ToString();
                    bc1.Remark = this.forecastReport.ID.ToString() + "-" + type;
                    bc1.Title = row["Title"].ToString();
                    bc1.Color = 16711680;
                    bc1.Color1 = Color.Blue;
                    Services.BaseService.Create<FORBaseColor>(bc1);
                    li.Add(bc1);
                }

            }
            ArrayList hs = new ArrayList();
            foreach (FORBaseColor bc2 in li)
            {
                hs.Add(bc2.Color1);
            }

            List<Ps_Forecast_Math> listValues = new List<Ps_Forecast_Math>();

            for (int i = 0; i < this.treeList1.Nodes.Count; i++)
            {
                TreeListNode row = treeList1.Nodes[i];
                foreach (TreeListColumn col in treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        int yyear = int.Parse(col.FieldName.Replace("y", ""));
                        if (yyear >= syear && yyear <= eyear)
                        {
                            object obj = row[col.FieldName];
                            if (obj != DBNull.Value)
                            {
                                Ps_Forecast_Math v = new Ps_Forecast_Math();
                                v.ForecastID = forecastReport.ID;
                                v.ID = (string)row["ID"];
                                v.Title = row["Title"].ToString();
                                v.Sort = Convert.ToInt32(col.FieldName.Replace("y", ""));
                                v.y1990 = (double)row[col.FieldName];

                                listValues.Add(v);
                            }
                        }
                    }
                }

            }
            this.chart_user1.RefreshChart(listValues, "Title", "Sort", "y1990", hs);
        }
Beispiel #21
0
        private void LoadData()
        {
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                this.treeList1.Columns.Clear();

                //treeList1.Columns.Clear();
            }
            //((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit();
            AddFixColumn();

            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                AddColumn(i);
            }
            //((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit();
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = 0;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));

            this.treeList1.DataSource = dataTable;

            Application.DoEvents();

            bLoadingData = false;
            InitMenu();
        }
Beispiel #22
0
        private void Save()
        {
            //����

            foreach (DataRow dataRow in dataTable.Rows)
            {

                TreeListNode row = treeList1.FindNodeByKeyID(dataRow["ID"]);

                //for (int i = 0; i < this.treeList1.Nodes.Count; i++)
                //{
                //    TreeListNode row = this.treeList1.Nodes[i];
                Ps_Forecast_Math v = new Ps_Forecast_Math();
                v.ID = row["ID"].ToString();
                foreach (TreeListColumn col in this.treeList1.Columns)
                {
                    if (col.FieldName.IndexOf("y") > -1)
                    {
                        object obj = row[col.FieldName];
                        if (obj != DBNull.Value)
                        {
                            v.GetType().GetProperty(col.FieldName).SetValue(v, obj, null);
                        }
                    }
                }
                v.Col4 = "yes";
                try
                {
                    Services.BaseService.Update("UpdatePs_Forecast_MathByID", v);

                }
                catch { }
            }
            MsgBox.Show("����ɹ���");
        }
Beispiel #23
0
 private void treeList1_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
 {
     TreeListNode row = this.treeList1.FocusedNode;
     if (row == null)
         return;
     Ps_Forecast_Math pf = new Ps_Forecast_Math();
     ForecastClass1.TreeNodeToDataObject<Ps_Forecast_Math>(pf,row);
     Services.BaseService.Update<Ps_Forecast_Math>(pf);
     CalculateSum2(row);
     //aaa(row);
     RefreshChart();
 }
Beispiel #24
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FormForecastLoadData2 ffs = new FormForecastLoadData2();
            ffs.PID = MIS.ProgUID;
            ffs.StartYear = forecastReport.StartYear;
            ffs.EndYear = forecastReport.EndYear;
            if (ffs.ShowDialog() != DialogResult.OK)
                return;

            Hashtable hs = ffs.HS;

            if (hs.Count == 0)
                return;
            string id = Guid.NewGuid().ToString();

                foreach (Ps_History de3 in hs.Values)
                {
                    if (OldHt.ContainsKey(de3.Title))
                    {
                        Ps_Forecast_Math py = Common.Services.BaseService.GetOneByKey<Ps_Forecast_Math>(OldHt[de3.Title]);
                        for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                        {
                            commonhelp.ResetValue(py.ID, "y" + i);
                            py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                        }

                        Services.BaseService.Update<Ps_Forecast_Math>(py);
                    }
                    else
                    {
                        Ps_Forecast_Math ForecastMath = new Ps_Forecast_Math();
                        ForecastMath.Title = de3.Title;

                        for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                        {
                            ForecastMath.GetType().GetProperty("y" + i).SetValue(ForecastMath, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                        }
                        id = id.Substring(0, 8);

                        ForecastMath.Col1 = de3.ID;
                        ForecastMath.ID = id + "|" + de3.ID;
                        if (de3.ParentID == "")
                        {
                            ForecastMath.ParentID = "";
                        }
                        else
                        {
                            ForecastMath.ParentID = id + "|" + de3.ParentID;
                        }

                        ForecastMath.Forecast = type;
                        ForecastMath.ForecastID = forecastReport.ID;
                        ForecastMath.Sort = de3.Sort;
                        Services.BaseService.Create("InsertPs_Forecast_MathbyPs_History", ForecastMath);
                    }
                }

            LoadData();

            this.chart_user1.All_Select(true);
            RefreshChart();
        }
Beispiel #25
0
        private void barButtonItem15_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode row = this.treeList1.FocusedNode;
            if (row == null)
            {
                return;
            }

            FormTypeTitle frm = new FormTypeTitle();
            frm.Text = "�����ӷ���";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
                psp_Type.ParentID = row["ID"].ToString();

                psp_Type.ID = Guid.NewGuid().ToString();

                psp_Type.Forecast = 0;
                psp_Type.ForecastID = forecastReport.ID;

                psp_Type.Title = frm.TypeTitle;
                object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null);
                if (obj != null)
                    psp_Type.Sort = ((int)obj) + 1;
                else
                    psp_Type.Sort = 1;

                try
                {
                    Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type);
                    //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));

                }
                catch (Exception ex)
                {
                    MsgBox.Show("���ӷ�������" + ex.Message);
                }
                RefreshChart();
            }
        }
Beispiel #26
0
        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Hashtable temphs = new Hashtable();
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            Common.Services.BaseService.Update("DeletePs_Forecast_MathForecastIDAndForecast", psp_Type);
            psp_Type.Forecast = 0;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);
            //foreach (Ps_Forecast_Math psp_Typetemp in listTypes)
            //{
            //    temphs.Add(psp_Typetemp.ID, Guid.NewGuid().ToString());
            //}
            foreach (Ps_Forecast_Math psp_Typetemp in listTypes)
            {
                string id = psp_Typetemp.ID;
                psp_Type = new Ps_Forecast_Math();
                psp_Type = psp_Typetemp;
                psp_Type.ID = Guid.NewGuid().ToString();
                psp_Type.Col1 =id;
                psp_Type.Forecast = type;
                if (psp_Type.ParentID != "")
                {
                    if (temphs.ContainsKey(psp_Type.ParentID))
                    {
                        psp_Type.ParentID = temphs[psp_Type.ParentID].ToString();
                    }
                }

                Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type);
            }
            LoadData();
            this.chart_user1.All_Select(true);
            RefreshChart();
        }
Beispiel #27
0
        private void barButtonItem24_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode row = this.treeList1.FocusedNode;
            if (row == null)
            {
                return;
            }

            if (row.Nodes.Count > 0)
            {
                MsgBox.Show("���¼����࣬����ɾ��");
                return;
            }

            string parentid = row["ParentID"].ToString();

            if (MsgBox.ShowYesNo("�Ƿ�ɾ������ " + row["Title"].ToString() + "��") == DialogResult.Yes)
            {
                Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
                ForecastClass1.TreeNodeToDataObject(psp_Type, row);
                //psp_Type = Itop.Common.DataConverter.RowToObject<Ps_Forecast_Math>(row);
                Ps_Forecast_Math psp_Values = new Ps_Forecast_Math();
                psp_Values.ID = psp_Type.ID;

                try
                {
                    //DeletePSP_ValuesByType����ɾ�����ݺͷ���
                    Common.Services.BaseService.Delete<Ps_Forecast_Math>(psp_Values);
                    FORBaseColor bc1 = new FORBaseColor();

                    bc1.Remark = forecastReport.ID+ "-" + typeFlag;
                    bc1.Title = row["Title"].ToString();
                    Common.Services.BaseService.Update("DeleteFORBaseColorByTitleRemark", bc1);

                    this.treeList1.Nodes.Remove(row);
                }
                catch (Exception ex)
                {
                    this.Cursor = Cursors.WaitCursor;
                    LoadData();
                    this.Cursor = Cursors.Default;
                }
                RefreshChart();
            }
        }
Beispiel #28
0
        private void checkfixedvalue()
        {
            ht.Clear();
            if (forecastReport.Col1 == "1")
            {
                ht.Add("ȫ�����󸺺ɣ�MW��", 1);
            }
            else
            {
                ht.Add("ȫ����õ�������kWh��", 1);
            }

            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));

            commonhelp.CheckHasFixValue(ht, dataTable, forecastReport.ID, type);
        }
Beispiel #29
0
        private void barButtonItem32_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = 0;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);
            IList<Ps_History> fhcol = new List<Ps_History>();
            bool flag = false;                   //�ж���û�� ��󸺺��������� ����ƽ���¶�
            foreach (Ps_Forecast_Math pm in listTypes)
            {
                if (pm.Title.Contains("��󸺺�"))
                {

                    Ps_History ph = new Ps_History();
                    ph.ID = pm.Col1;
                    ph = (Ps_History)Services.BaseService.GetObject("SelectPs_HistoryByKey", ph);
                    if (ph!=null)
                    {
                        flag = true;
                        Ps_History pr = new Ps_History();
                        pr.ID = ph.ParentID;
                        pr = (Ps_History)Services.BaseService.GetObject("SelectPs_HistoryByKey", pr);
                        if (pr!=null)
                        {
                            ph.Title = pr.Title + ph.Title;
                        }
                        fhcol.Add(ph);
                    }
                }
            }
            if (!flag)
            {
                MsgBox.Show("Ԥ�������в����ڸ������ݣ��뵼�����ݺ��ٲ�����");
                return;
            }

            //string con = "Title='��ƽ���¶�' AND Col4='" + ProjectUID + "'AND Forecast='1'";
            Ps_History wd = (Ps_History)Services.BaseService.GetObject("SelectPs_HistoryByCondition", "Title like'%��ƽ���¶�%' AND Col4='" + Itop.Client.MIS.ProgUID + "'AND Forecast='1'");
            if (wd!=null)
            {
                fhcol.Add(wd);
            }
            else
            {
                MsgBox.Show("�ڵ�����չʵ�������趨��ƽ���¶ȣ�");
                return;
            }

            FormForecastWDXS wdxs = new FormForecastWDXS(fhcol);
            wdxs.temk1 = temtk1;
            wdxs.temk2 = temtk2;
            if (wdxs.ShowDialog()==DialogResult.OK)
            {
                foreach(Ps_History de3 in wdxs.fucol)
                {
                    temtk1 = wdxs.temk1;
                    temtk2 = wdxs.temk2;
                    Ps_Forecast_Math py = new Ps_Forecast_Math();
                    py.Col1 = de3.ID;
                    py.Forecast = 0;
                    py.ForecastID = forecastReport.ID;
                    py = (Ps_Forecast_Math)Services.BaseService.GetObject("SelectPs_Forecast_MathByCol1", py);
                    if (py != null)
                    {

                        for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                        {
                            py.GetType().GetProperty("y" + i).SetValue(py, de3.GetType().GetProperty("y" + i).GetValue(de3, null), null);
                        }
                        Services.BaseService.Update<Ps_Forecast_Math>(py);

                    }

                }

            }
            LoadData();
            RefreshChart();
        }
Beispiel #30
0
        private void LoadData()
        {
            checkfixedvalue();
            treeList1.DataSource = null;
            bLoadingData = true;
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                treeList1.Columns.Clear();
            }
            AddFixColumn();
            for (int i = forecastReport.StartYear; i <= forecastReport.YcEndYear; i++)
            {
                AddColumn(i);
            }
            Ps_Forecast_Math psp_Type = new Ps_Forecast_Math();
            psp_Type.ForecastID = forecastReport.ID;
            psp_Type.Forecast = type;
            IList listTypes = Common.Services.BaseService.GetList("SelectPs_Forecast_MathByForecastIDAndForecast", psp_Type);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(Ps_Forecast_Math));

            treeList1.DataSource = dataTable;
            OldHt.Clear();
            foreach (DataRow row in dataTable.Rows)
            {
                if (!OldHt.ContainsKey(row["Title"].ToString()))
                {
                    OldHt.Add(row["Title"].ToString(), row["ID"].ToString());
                }
            }

            treeList1.Columns["Title"].OptionsColumn.AllowEdit = false;

            Application.DoEvents();
            bLoadingData = false;
        }