private void FormForecastCalcTX_Load(object sender, EventArgs e) { #region ������չʵ�� ArrayList al = new ArrayList(); IList<Base_Data> li1 = Common.Services.BaseService.GetStrongList<Base_Data>(); foreach (Base_Data bd in li1) al.Add(bd.Title); Ps_History psp_Type1 = new Ps_History(); psp_Type1.Forecast = 1; psp_Type1.Col4 = Itop.Client.MIS.ProgUID; IList<Ps_History> listTypes1 = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type1); for (int c = 0; c < al.Count; c++) { bool bl = true; foreach (Ps_History ph in listTypes1) { if (al[c].ToString() == ph.Title) bl = false; } if (bl) { Ps_History pf = new Ps_History(); pf.ID = Guid.NewGuid().ToString() + "|" + Itop.Client.MIS.ProgUID; pf.Forecast = 1; pf.ForecastID = "1"; pf.Title = al[c].ToString(); pf.Col4 = Itop.Client.MIS.ProgUID; Services.BaseService.Create<Ps_History>(pf); listTypes1.Add(pf); } } 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 = 1; 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='ȫ����GDP����Ԫ��'"); DataRow[] rows4 = dataTable.Select("Title='ȫ����õ�������kWh��'"); #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.EndYear; 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); foreach (Ps_Calc pcs2 in list1) { if (i == pcs2.Year) { newrow1[i.ToString()] = Math.Round(pcs2.Value1,3); newrow2[i.ToString()] = Math.Round(pcs2.Value2,3); } } } dt.Rows.Add(newrow1); dt.Rows.Add(newrow2); vGridControl2.DataSource = dt; }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListMultiSelection tm = treeList1.Selection; if (tm.Count == 0) return; DataRow dr = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle); if (dr == null) return; int id1 = (int)dr["ID"]; hs.Clear(); li.Clear(); if (Flag=="1")//�ɰ�����ع���ʵ�� { if (id1 != 4) { foreach (TreeListNode tln in tm) { Ps_History pt1 = new Ps_History(); Ps_History pt = Services.BaseService.GetOneByKey<Ps_History>((string)tln["ID"]); if (tln["Title"].ToString() == "�����õ���" || tln["Title"].ToString() == "���渺��") { pt.Title = pt.Title + "-" + tln.ParentNode["Title"]; } else if (!tln["Title"].ToString().Contains("����") && !tln["Title"].ToString().Contains("����")) { if (id1 == 2) pt.Title = pt.Title + "����"; else if (id1 == 3) pt.Title = pt.Title + "����"; } if (!hs.ContainsValue(pt)) hs.Add(Guid.NewGuid().ToString(), pt); } } else { foreach (TreeListNode tln in tm) { PSP_Types pt = Services.BaseService.GetOneByKey<PSP_Types>((int)tln["ID"]); if (!hs.ContainsValue(pt)) hs.Add(Guid.NewGuid().ToString(), pt); } } } else//�°�����ع���ʵ�� { foreach (TreeListNode tln in tm) { Ps_History pt1 = new Ps_History(); Ps_History pt = Services.BaseService.GetOneByKey<Ps_History>((string)tln["ID"]); if (tln["Title"].ToString() == "�����õ���" || tln["Title"].ToString() == "���渺��") { pt.Title = pt.Title + "-" + tln.ParentNode["Title"]; } else if (!tln["Title"].ToString().Contains("����") && !tln["Title"].ToString().Contains("����")) { if (id1 == 2) pt.Title = pt.Title + "����"; else if (id1 == 3) pt.Title = pt.Title + "����"; } if (!hs.ContainsValue(pt)) hs.Add(Guid.NewGuid().ToString(), pt); } } if (hs.Count > 0) this.DialogResult = DialogResult.OK; }
private void LoadData1(int id) { if (dataTable != null) { dataTable.Columns.Clear(); treeList1.Columns.Clear(); } ((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit(); AddFixColumn(); for (int i = startyear; i <= endyear; i++) { AddColumn(i); } ((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit(); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = id; psp_Type.Col4 = pid; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); treeList1.DataSource = dataTable; treeList1.Columns["Sort"].SortOrder = SortOrder.Ascending; treeList1.Columns["Title"].Caption = "������"; treeList1.Columns["Title"].Width = 180; treeList1.Columns["Title"].OptionsColumn.AllowEdit = false; treeList1.Columns["Title"].OptionsColumn.AllowSort = false; Application.DoEvents(); treeList1.CollapseAll(); //LoadValues1(htt); //treeList1.Nodes[0].Expanded = true; //treeList1.ExpandAll(); }
//���µ緢����ʵ���е���� private void RefreshData_JJ() { //�ı�treelist1�Ľ����㣬Ȼ���ٱ����������treelist1�Ż����ֵ if (treeList1.FocusedNode != null) { TreeListNode node = treeList1.FocusedNode; treeList1.FocusedNode = null; treeList1.FocusedNode = node; } //�������б� AddListID.Clear(); AddList.Clear(); //��ռ����б� ReduceListID.Clear(); ReduceList.Clear(); //��ոı䵥λ�б� changeUnitlist.Clear(); changeUnitlistID.Clear(); AddorReduListBynode(treeList1.Nodes, AddList, ReduceList); if (AddList.Count == 0 && ReduceList.Count == 0 && changeUnitlist.Count == 0) { MsgBox.Show("��δ���κ��ģ�����Ҫ����ģ�飡"); return; } FormHistoryTypeEditDeal frm = new FormHistoryTypeEditDeal(); frm.TypeTitle = "��ȷ�����Ƿ�Ҫ���������ı䣿"; frm.addlist = AddList; frm.reducelist = ReduceList; frm.changeUnitslist = changeUnitlist; if (frm.ShowDialog() == DialogResult.OK) { if (AddListID.Count != 0) { for (int i = 0; i < AddListID.Count; i++) { //Ps_HistoryType pht = new Ps_HistoryType(); //pht.ID = AddListID[i]; Ps_HistoryType pht = Common.Services.BaseService.GetOneByKey<Ps_HistoryType>(AddListID[i]); ; Ps_History pf = new Ps_History(); pf.ID = pht.ID + "|" + ProjectID; pf.Forecast = Forecast; pf.ForecastID = ForecastID; TreeListNode node = treeList1.FindNodeByKeyID(pht.ID); string tempstr = string.Empty; pf.Title = AddList[i].ToString(); pf.ParentID = pht.ParentID + "|" + ProjectID; pf.Col4 = MIS.ProgUID; //��ʶ��Ĭ��������� pf.Col10 = "1"; pf.Sort = pht.Sort; try { Common.Services.BaseService.Create<Ps_History>(pf); FormHistoryJJ.Historyhome.dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(pf, FormHistoryJJ.Historyhome.dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("���ӷ�������" + ex.Message); } FormHistoryJJ.Historyhome.RefreshChart(); } } if (ReduceListID.Count != 0) { for (int i = 0; i < ReduceListID.Count; i++) { TreeListNode node = FormHistoryJJ.Historyhome.treeList1.FindNodeByKeyID(ReduceListID[i].ToString() + "|" + ProjectID); if (node != null) { FormHistoryJJ.Historyhome.DeleteNode(node); } } } if (changeUnitlistID.Count != 0) { for (int i = 0; i < changeUnitlistID.Count; i++) { try { Ps_History pht = Common.Services.BaseService.GetOneByKey<Ps_History>(changeUnitlistID[i] + "|" + ProjectID); pht.Title = changeUnitlist[i].ToString(); Common.Services.BaseService.Update<Ps_History>(pht); TreeListNode node = FormHistoryJJ.Historyhome.treeList1.FindNodeByKeyID(changeUnitlistID[i].ToString() + "|" + ProjectID); if (node != null) { node["Title"] = changeUnitlist[i].ToString(); } } catch (Exception ex) { MsgBox.Show("�ĵ�λ�����" + ex.Message); } } } FormHistoryJJ.Historyhome.treeList1.Refresh(); EqueValueBynode(treeList1.Nodes); treeList1.Refresh(); MsgBox.Show("�������!"); } }
private void InitData() { Ps_YearRange py = new Ps_YearRange(); py.Col4 = yearflag; py.Col5 = projectUID; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 1990; endyear = 2020; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = pstype; psp_Type.Col4 = projectUID; 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)); Ps_History psp_Typejj = new Ps_History(); psp_Typejj.Forecast = 5; psp_Typejj.Col4 = projectUID; IList<Ps_History> listTypesjj = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Typejj); DataTable dataTablejj = Itop.Common.DataConverter.ToDataTable((IList)listTypesjj, typeof(Ps_History)); DataRow[] rows1 = dataTablejj.Select("Title like 'ȫ����GDP%'"); // DataRow[] rows2 = dataTable.Select("Title like 'ȫ��ṩ����%'"); DataRow[] rows4 = dataTable.Select("Title like 'ȫ����õ���%'"); //DataRow[] rows5 = dataTable.Select("Title like 'ȫ������%'"); DataRow[] rows7 = dataTablejj.Select("Title like '��ĩ���˿�%'"); DataRow[] rows8 = dataTable.Select("Title='�����õ�'"); if (rows1.Length==0) { MessageBox.Show("ȱ��ȫ����GDP����!"); this.Close(); return; } //if (rows2.Length == 0) //{ // MessageBox.Show("ȱ��ȫ��ṩ��������!"); // this.Close(); //} if (rows4.Length == 0) { MessageBox.Show("ȱ��ȫ����õ�������!"); this.Close(); return; } //if (rows5.Length == 0) //{ // MessageBox.Show("ȱ��ȫ����������!"); // this.Close(); //} if (rows7.Length == 0) { MessageBox.Show("ȱ����ĩ���˿�����!"); this.Close(); return; } GDPUnits = Historytool.FindUnits(rows1[0]["Title"].ToString()); //ȫ��ṩ������λ //AGdlUnits = Historytool.FindUnits(rows2[0]["Title"].ToString()); //ȫ����õ�����λ AYdlUnits = Historytool.FindUnits(rows4[0]["Title"].ToString()); //ȫ�����ɵ�λ // AMaxFhUnits = Historytool.FindUnits(rows5[0]["Title"].ToString()); //��ĩ���˿ڵ�λ NMARkUnits = Historytool.FindUnits(rows7[0]["Title"].ToString()); string pid = rows1[0]["ID"].ToString(); string sid = rows4[0]["ID"].ToString(); ///ȫ����GDP���� DataRow[] rows3 = dataTable.Select("ParentID='"+pid+"'"); ///������õ������� DataRow[] rows6 = dataTable.Select("ParentID='" + sid + "'"); int m=-1; this.gridControl1.BeginInit(); this.gridControl1.BeginUpdate(); bool isfirst = true; for (int i = firstyear; i <= endyear; i++) { dt.Columns.Add("y" + i, typeof(double)); if (!ht.ContainsValue(i)) continue; if (IsFist) { RealFistYear = i; IsFist = false; } m++; //dt.Columns.Add("y" + i, typeof(double)); GridColumn gridColumn = new GridColumn(); gridColumn.Caption = i+"��"; gridColumn.FieldName = "y" + i; gridColumn.Visible = true; gridColumn.VisibleIndex = 2*m+10; gridColumn.Width = 70; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns.Add(gridColumn); if (ht1.ContainsValue(i)) { if (isfirst) { isfirst = false; } else { gridColumn = new GridColumn(); gridColumn.Caption = "���������(%)"; gridColumn.FieldName = "m" + i; gridColumn.Visible = true; gridColumn.Width = 130; gridColumn.VisibleIndex = 2 * m + 11; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns.Add(gridColumn); dt.Columns.Add("m" + i, typeof(double)); } } if (ht2.ContainsValue(i)) { gridColumn = new GridColumn(); gridColumn.Caption = "����������(%)"; gridColumn.FieldName = "n" + i; gridColumn.Visible = true; gridColumn.Width = 130; gridColumn.VisibleIndex = 2 * m + 12; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns.Add(gridColumn); dt.Columns.Add("n" + i, typeof(double)); } } this.gridControl1.EndUpdate(); this.gridControl1.EndInit(); double sum = 0;// ȫ����GDP���� try { sum = Convert.ToDouble(rows1[0]["y" + firstyear]); } catch { } double sum51 = 0;// ȫ����õ������� try { sum51 = Convert.ToDouble(rows4[0]["y" + firstyear]); } catch { } double sum52 = 0; double sum53 = 0; double sum1 = 0; double sum2 = 0; double sum3 = 0; double sum4 = 0; double sum5 = 0; double sum6 = 0; double sum7 = 0; double sum8 = 0; double sum9 = 0; double sum10 = 0; double sum11 = 0; double sum12 = 0; double sum13 = 0; DataRow row = dt.NewRow(); DataRow row3 = dt.NewRow(); DataRow row4 = dt.NewRow(); DataRow row5 = dt.NewRow(); DataRow row6 = dt.NewRow(); DataRow row7 = dt.NewRow(); DataRow row8 = dt.NewRow(); DataRow row9 = dt.NewRow(); DataRow row10 = dt.NewRow(); DataRow row11 = dt.NewRow(); row["ID"] = Guid.NewGuid().ToString(); row["Title"] = "һ������������ֵ(GDP,"+GDPUnits+")"; m = firstyear; for (int j = firstyear; j <= endyear; j++) { //if (!ht.ContainsValue(j)) lyh // continue; try { sum1 = Convert.ToDouble(rows1[0]["y" + j]); } catch { } row["y" + j] = sum1; try { sum51 = Convert.ToDouble(rows4[0]["y" + j]); } catch { } if (m != firstyear)//��ʾ���ǵ�һ�꣬�Ժ�����Ҫ������ { try { sum2 = Convert.ToDouble(rows1[0]["y" + (j - 1)]); } catch { } try { sum52 = Convert.ToDouble(rows4[0]["y" + (j - 1)]); } catch { } if (sum52 != 0) sum53 = sum51 * 100 / sum52-100;//�õ������� if (sum2 != 0) sum3 = sum1 * 100 / sum2-100;//GDP���� row3["y" + j] = sum3; } else row3["y" + j] = 1; try { sum4 = Convert.ToDouble(rows4[0]["y" + j]); } catch { } row4["y" + j] = sum4;//�õ��� //try { sum5 = Convert.ToDouble(rows5[0]["y" + j]); } //catch { } //row5["y" + j] = sum5;//��� //if (sum5 != 0) // sum6 = sum4 * 10000 / sum5; //row6["y" + j] = sum6;// ����ȫ����������Сʱ�� //try { sum7 = Convert.ToDouble(rows2[0]["y" + j]); } //catch { } if (m != firstyear) { //if (sum53 != 0) // sum8 = sum3 / sum53; //row7["y" + j] = sum8;//ԭ���� if (sum3 != 0) sum8 = sum53 / sum3; row7["y" + j] = sum8;//����ϵ�����������������ٶ�����������ı�ֵlgm } else row7["y" + j] = 1; try { sum9 = Convert.ToDouble(rows7[0]["y" + j]); }//��ĩ�˿� catch { } if (sum9 != 0) { if (AYdlUnits.Contains("��") && NMARkUnits.Contains("����"))//��kWh ���� { sum10 = sum51 * 10000 / sum9;//�˾��õ��� } else if (AYdlUnits.Contains("��") && NMARkUnits.Contains("����"))//��kWh ���� { sum10 = sum51 / sum9;//�˾��õ��� } else { MessageBox.Show("ȫ����õ�������ĩ���˿ڵĵ�λ��������Ĭ��������϶ԣ�����kWh,��kWh,���ˣ�"); this.Close(); return; } } row8["y" + j] = sum10; if (sum1 != 0) { if (AYdlUnits.Contains("��")&&GDPUnits.Contains("��Ԫ"))//��kWh ��Ԫ { sum11 = sum4 * 10000 / sum1;//�������� } else if (AYdlUnits.Contains("��") && GDPUnits.Contains("��Ԫ"))//��kWh ��Ԫ { sum11 = sum4 / sum1;//�������� } else { MessageBox.Show("ȫ����õ�����ȫ����GDP�ĵ�λ��������Ĭ��������϶ԣ�����kWh,��kWh,��Ԫ��"); this.Close(); return; } } row9["y" + j] = sum11;//�������� if (rows8.Length > 0) { try { sum12 = Convert.ToDouble(rows8[0]["y" + j]); } catch { } row11["y" + j] = sum12; if (sum9 != 0) { if (AYdlUnits.Contains("��") && NMARkUnits.Contains("����"))//��kWh ���� { sum13 = sum12 * 10000 / sum9;//�����õ� } else if (AYdlUnits.Contains("��") && NMARkUnits.Contains("����"))//��kWh ���� { sum13 = sum12 / sum9;//�����õ� } else { MessageBox.Show("ȫ����õ�������ĩ���˿ڵĵ�λ��������Ĭ��������϶ԣ�����kWh,��kWh,���ˣ�"); this.Close(); return; } } row10["y" + j] = sum13; } else { row10["y" + j] = sum13; } m++; } dt.Rows.Add(row); for (int k = 0; k < rows3.Length; k++) { double su1 = 0; double su2 = 0; double su3 = 0; DataRow ro1 = dt.NewRow(); ro1["ID"] = Guid.NewGuid().ToString(); ro1["Title"] = rows3[k]["Title"].ToString(); DataRow ro2 = dt.NewRow(); ro2["ID"] = Guid.NewGuid().ToString(); ro2["Title"] = "������%��"; for (int j = firstyear; j <= endyear; j++) { if (!ht.ContainsValue(j)) continue; try { su1 = Convert.ToDouble(rows1[0]["y" + j]); } catch { } su2 = 0; su3 = 0; try { su2 = Convert.ToDouble(rows3[k]["y" + j]); } catch { } ro1["y" + j] = su2; if (su1 != 0) su3 = su2 * 100 / su1; ro2["y" + j] = su3; } dt.Rows.Add(ro1); dt.Rows.Add(ro2); } row3["ID"] = Guid.NewGuid().ToString(); row3["Title"] = "����������ֵ�����ʣ�����"; dt.Rows.Add(row3); row4["ID"] = Guid.NewGuid().ToString(); row4["Title"] = "����ȫ����õ���("+AYdlUnits+")"; dt.Rows.Add(row4); //row5["ID"] = Guid.NewGuid().ToString(); //row5["Title"] = "��ɣ���ǧ�ߣ�"; //dt.Rows.Add(row5); //row6["ID"] = Guid.NewGuid().ToString(); //row6["Title"] = "�������Сʱ��(Сʱ)"; //dt.Rows.Add(row6); for (int k = 0; k < rows6.Length; k++) { double su1 = 0; double su2 = 0; double su3 = 0; DataRow ro1 = dt.NewRow(); ro1["ID"] = Guid.NewGuid().ToString(); ro1["Title"] = rows6[k]["Title"].ToString(); DataRow ro2 = dt.NewRow(); ro2["ID"] = Guid.NewGuid().ToString(); ro2["Title"] = "������%��"; for (int j = firstyear; j <= endyear; j++) { if (!ht.ContainsValue(j)) continue; try { su1 = Convert.ToDouble(rows4[0]["y" + j]); } catch { } su2 = 0; su3 = 0; try { su2 = Convert.ToDouble(rows6[k]["y" + j]); } catch { } ro1["y" + j] = su2; if (su1 != 0) su3 = su2 * 100 / su1; ro2["y" + j] = su3; } dt.Rows.Add(ro1); dt.Rows.Add(ro2); } row7["ID"] = Guid.NewGuid().ToString(); row7["Title"] = "����ϵ��"; dt.Rows.Add(row7); row8["ID"] = Guid.NewGuid().ToString(); row8["Title"] = "�˾��õ�����ǧ��ʱ/�ˣ�"; dt.Rows.Add(row8); row9["ID"] = Guid.NewGuid().ToString(); row9["Title"] = "GDP���ģ�ǧ��ʱ/��Ԫ��"; dt.Rows.Add(row9); for (int k = 0; k < rows6.Length; k++) { double su1 = 0; double su2 = 0; double su3 = 0; DataRow ro1 = dt.NewRow(); ro1["ID"] = Guid.NewGuid().ToString(); ro1["Title"] = rows6[k]["Title"].ToString(); for (int j = firstyear; j <= endyear; j++) { if (!ht.ContainsValue(j)) continue; su1 = 0; su2 = 0; su3 = 0; try { su1 = Convert.ToDouble(rows6[k]["y" + j]); } catch { } try { su2 = Convert.ToDouble(rows3[k]["y" + j]); } catch { } if (su2 != 0) { su3 = su1 * 10000 / su2; } else su3 = su1; ro1["y" + j] = su3; } if (rows6[k]["Title"].ToString().IndexOf("����") >= 0) continue; dt.Rows.Add(ro1); } row10["ID"] = Guid.NewGuid().ToString(); row10["Title"] = "�����õ磨ǧ��ʱ/�ˣ�"; dt.Rows.Add(row10); double d = 0; //��������� foreach(DataRow drw1 in dt.Rows) { foreach (DataColumn dc in dt.Columns) { if (dc.ColumnName.IndexOf("m") >= 0) { string s = dc.ColumnName.Replace("m", ""); int y1 = int.Parse(s); double d1 = 0; try { d1 = (double)drw1["y" + s]; } catch { } int peryear = 0; for (int i = y1-1; i >0;i-- ) { if (ht1.ContainsValue(i)) { peryear = i; break; } } try { d = (double)drw1["y" + peryear]; } catch { } double sss = Math.Round(Math.Pow(d1 / d, 1.0 / (y1 - peryear)) - 1, 4); sss *= 100; if (sss.ToString() == "������" || sss.ToString() == "�������") sss = 0; drw1["m" + s]=sss; } } } //���������� double dd = 0; foreach (DataRow drw1 in dt.Rows) { foreach (DataColumn dc in dt.Columns) { if (dc.ColumnName.IndexOf("n") >= 0) { string s = dc.ColumnName.Replace("n", ""); int y1 = int.Parse(s); double d1 = 0; try { d1 = (double)drw1["y" + s]; } catch { } try { dd = (double)drw1["y" + (y1-1)]; } catch { } double sss = Math.Round(Math.Pow(d1 / dd, 1.0 / 1) - 1, 4); sss *=100; if (sss.ToString() == "������" || sss.ToString() == "�������") sss = 0; drw1["n" + s] = sss; } } } this.gridControl1.DataSource = dt; }
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(); }
private void InitData() { Ps_YearRange py = new Ps_YearRange(); py.Col4 = yearflag; py.Col5 = projectUID; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 1990; endyear = 2020; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = pstype; psp_Type.Col4 = projectUID; 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)); int m=-1; this.gridControl1.BeginInit(); this.gridControl1.BeginUpdate(); bool isfirst = true; for (int i = firstyear; i <= endyear; i++) { if (!ht.ContainsValue(i)) continue; if (IsFist) { RealFistYear = i; IsFist = false; } m++; GridColumn gridColumn = new GridColumn(); gridColumn.Caption = i+"��"; gridColumn.FieldName = "y" + i; gridColumn.Visible = true; gridColumn.VisibleIndex = 2*m+10; gridColumn.Width = 70; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns.Add(gridColumn); if (ht1.ContainsValue(i)) { if (isfirst) { isfirst = false; } else { gridColumn = new GridColumn(); gridColumn.Caption = "���������(%)"; gridColumn.FieldName = "mm" + i; gridColumn.Visible = true; gridColumn.Width = 130; gridColumn.VisibleIndex = 2 * m + 11; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns.Add(gridColumn); dataTable.Columns.Add("mm" + i, typeof(double)); } } if (ht2.ContainsValue(i)) { gridColumn = new GridColumn(); gridColumn.Caption = "����������(%)"; gridColumn.FieldName = "nn" + i; gridColumn.Visible = true; gridColumn.Width = 130; gridColumn.VisibleIndex = 2 * m + 12; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridView1.Columns.Add(gridColumn); dataTable.Columns.Add("nn" + i, typeof(double)); } } this.gridControl1.EndUpdate(); this.gridControl1.EndInit(); double d = 0; //��������� foreach (DataRow drw1 in dataTable.Rows) { foreach (DataColumn dc in dataTable.Columns) { if (dc.ColumnName.IndexOf("mm") >= 0) { string s = dc.ColumnName.Replace("mm", ""); int y1 = int.Parse(s); double d1 = 0; try { d1 = (double)drw1["y" + s]; } catch { } int peryear = 0; for (int i = y1-1; i >0; i--) { if ( ht1.ContainsValue(i)) { peryear = i; break; } } try { d = (double)drw1["y" + peryear]; } catch { } double sss = Math.Round(Math.Pow(d1 / d, 1.0 / (y1 - peryear)) - 1, 4); sss *= 100; if (sss.ToString() == "������" || sss.ToString() == "�������") sss = 0; drw1["mm" + s]=sss; } } } //���������� double dd = 0; foreach (DataRow drw1 in dataTable.Rows) { foreach (DataColumn dc in dataTable.Columns) { if (dc.ColumnName.IndexOf("nn") >= 0) { string s = dc.ColumnName.Replace("nn", ""); int y1 = int.Parse(s); double d1 = 0; try { d1 = (double)drw1["y" + s]; } catch { } try { dd = (double)drw1["y" + (y1-1)]; } catch { } double sss = Math.Round(Math.Pow(d1 / dd, 1.0 / 1) - 1, 4); sss *=100; if (sss.ToString() == "������" || sss.ToString() == "�������") sss = 0; drw1["nn" + s] = sss; } } } this.gridControl1.DataSource = dataTable; }
private System.Data.DataTable getfqxdltable() { System.Data.DataTable dataTable = new System.Data.DataTable(); string type1 = "2"; int type = 2; string type31 = "3"; int type32 = 3; ArrayList al = new ArrayList(); al.Add("全社会"); //Dictionary<string, string> al = new Dictionary<string, string>(); //al.Add("全社会用电量(亿kWh)", ""); //al.Add( //IList<Base_Data> li1 = Common.Services.BaseService.GetStrongList<Base_Data>(); //foreach (Base_Data bd in li1) // al.Add(bd.Title); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = type; psp_Type.Col4 = ProjectUID; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); //foreach (Ps_History ph in listTypes) // { // Common.Services.BaseService.Delete<Ps_History>(ph); // } if (listTypes.Count == 0) { Ps_History pf = new Ps_History(); pf.ID = createID(); //pf.ParentID = ""; pf.Sort = -1; pf.Forecast = type; pf.ForecastID = type1; pf.Title = "全社会"; pf.Col4 = ProjectUID; Services.BaseService.Create<Ps_History>(pf); listTypes.Add(pf); Ps_History pf2 = new Ps_History(); pf2.ID = pf.ID + splitstr; //pf.ParentID = ""; pf2.Sort = -1; pf2.Forecast = type32; pf2.ForecastID = type31; pf2.Title = pf.Title; pf2.Col4 = ProjectUID; Services.BaseService.Create<Ps_History>(pf2); } dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); return dataTable; }
private System.Data.DataTable getfqxdltable2( System.Data.DataTable datatable) { string type1 = "2"; int type = 2; string type31 = "3"; int type32 = 3; System.Data.DataTable dataTable2 = new System.Data.DataTable(); ArrayList al = new ArrayList(); al.Add("全社会"); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = type32; psp_Type.Col4 = ProjectUID; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); //foreach (Ps_History ph in listTypes) // { // Common.Services.BaseService.Delete<Ps_History>(ph); // } if (listTypes.Count == 0) { DataRow[] node = datatable.Select("Title='"+ al[0].ToString()+"'") ; Ps_History pf = new Ps_History(); pf.ID = node[0]["ID"] + splitstr; //pf.ParentID = ""; pf.Sort = -1; pf.Forecast = type32; pf.ForecastID = type31; pf.Title = al[0].ToString(); pf.Col4 = ProjectUID; Services.BaseService.Create<Ps_History>(pf); listTypes.Add(pf); } dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); return dataTable2; }
//电力发展实绩社会经济用电情况 private void build_dlhistoryjjyd() { bool IsFist = true; int RealFistYear = 0; ; Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>(); string title = "电力发展实绩_分行业统计"; Ps_YearRange py = new Ps_YearRange(); py.Col4 = "电力发展实绩"; py.Col5 = Itop.Client.MIS.ProgUID; int firstyear, endyear; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 1990; endyear = 2020; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); viscol["Title"]=new Columqk("统计类别",3,2); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = 1; psp_Type.Col4 = Itop.Client.MIS.ProgUID; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); System.Data.DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'"); // DataRow[] rows2 = dataTable.Select("Title like '全社会供电量%'"); DataRow[] rows4 = dataTable.Select("Title like '全社会用电量%'"); //DataRow[] rows5 = dataTable.Select("Title like '全社会最大负荷%'"); DataRow[] rows7 = dataTable.Select("Title like '年末总人口%'"); DataRow[] rows8 = dataTable.Select("Title='居民用电'"); if (rows1.Length == 0) { MessageBox.Show("缺少全地区GDP数据!"); this.Close(); return; } //if (rows2.Length == 0) //{ // MessageBox.Show("缺少全社会供电量数据!"); // this.Close(); //} if (rows4.Length == 0) { MessageBox.Show("缺少全社会用电量数据!"); this.Close(); return; } //if (rows5.Length == 0) //{ // MessageBox.Show("缺少全社会最大负荷数据!"); // this.Close(); //} if (rows7.Length == 0) { MessageBox.Show("缺少年末总人口数据!"); this.Close(); return; } string GDPUnits = fpcommon.FindUnits(rows1[0]["Title"].ToString()); //全社会供电量单位 //AGdlUnits = Historytool.FindUnits(rows2[0]["Title"].ToString()); //全社会用电量单位 string AYdlUnits = fpcommon.FindUnits(rows4[0]["Title"].ToString()); //全社会最大负荷单位 // AMaxFhUnits = Historytool.FindUnits(rows5[0]["Title"].ToString()); //年末总人口单位 string NMARkUnits = fpcommon.FindUnits(rows7[0]["Title"].ToString()); string pid = rows1[0]["ID"].ToString(); string sid = rows4[0]["ID"].ToString(); ///全地区GDP子类 DataRow[] rows3 = dataTable.Select("ParentID='" + pid + "'"); ///会社会用电量子类 DataRow[] rows6 = dataTable.Select("ParentID='" + sid + "'"); int m = -1; for (int i = firstyear; i <= endyear; i++) { //如果点击统计按钮 if (shjjbyyear) { if (!ht.ContainsValue(i)) continue; } if (IsFist) { RealFistYear = i; IsFist = false; } m++; dt.Columns.Add("y" + i, typeof(double)); viscol["y"+i]=new Columqk(i+"年",2,2); //if (!ht1.ContainsValue(i)) // continue; dt.Columns.Add("m" + i, typeof(double)); viscol["m"+i]=new Columqk("年增长率(%)",1,2); } double sum = 0;// 全地区GDP数据 try { sum = Convert.ToDouble(rows1[0]["y" + firstyear]); } catch { } double sum51 = 0;// 全社会用电量数据 try { sum51 = Convert.ToDouble(rows4[0]["y" + firstyear]); } catch { } double sum52 = 0; double sum53 = 0; double sum1 = 0; double sum2 = 0; double sum3 = 0; double sum4 = 0; double sum5 = 0; double sum6 = 0; double sum7 = 0; double sum8 = 0; double sum9 = 0; double sum10 = 0; double sum11 = 0; double sum12 = 0; double sum13 = 0; DataRow row = dt.NewRow(); DataRow row3 = dt.NewRow(); DataRow row4 = dt.NewRow(); DataRow row5 = dt.NewRow(); DataRow row6 = dt.NewRow(); DataRow row7 = dt.NewRow(); DataRow row8 = dt.NewRow(); DataRow row9 = dt.NewRow(); DataRow row10 = dt.NewRow(); DataRow row11 = dt.NewRow(); row["ID"] = Guid.NewGuid().ToString(); row["Title"] = "一、地区生产总值(GDP," + GDPUnits + ")"; m = firstyear; for (int j = firstyear; j <= endyear; j++) { if (shjjbyyear) { if (!ht.ContainsValue(j)) continue; } try { sum1 = Convert.ToDouble(rows1[0]["y" + j]); } catch { } row["y" + j] = sum1; try { sum51 = Convert.ToDouble(rows4[0]["y" + j]); } catch { } if (m != firstyear)//表示不是第一年,以后的年份要算增长 { try { sum2 = Convert.ToDouble(rows1[0]["y" + (j - 1)]); } catch { } try { sum52 = Convert.ToDouble(rows4[0]["y" + (j - 1)]); } catch { } if (sum52 != 0) sum53 = sum51 * 100 / sum52 - 100;//用电量增长 if (sum2 != 0) sum3 = sum1 * 100 / sum2 - 100;//GDP增长 row3["y" + j] = sum3; } else row3["y" + j] = 1; try { sum4 = Convert.ToDouble(rows4[0]["y" + j]); } catch { } row4["y" + j] = sum4;//用电量 //try { sum5 = Convert.ToDouble(rows5[0]["y" + j]); } //catch { } //row5["y" + j] = sum5;//最大负荷 //if (sum5 != 0) // sum6 = sum4 * 10000 / sum5; //row6["y" + j] = sum6;// 计算全社会最大负荷利用小时数 //try { sum7 = Convert.ToDouble(rows2[0]["y" + j]); } //catch { } if (m != firstyear) { //if (sum53 != 0) // sum8 = sum3 / sum53; //row7["y" + j] = sum8;//原计算 if (sum3 != 0) sum8 = sum53 / sum3; row7["y" + j] = sum8;//弹性系数,电力消费增长速度与国民经济增长的比值lgm } else row7["y" + j] = 1; try { sum9 = Convert.ToDouble(rows7[0]["y" + j]); }//年末人口 catch { } if (sum9 != 0) { if (AYdlUnits.Contains("亿") && NMARkUnits.Contains("万人"))//亿kWh 万人 { sum10 = sum51 * 10000 / sum9;//人均用电量 } else if (AYdlUnits.Contains("万") && NMARkUnits.Contains("万人"))//万kWh 万人 { sum10 = sum51 / sum9;//人均用电量 } else { MessageBox.Show("全社会用电量或年末总人口的单位错误!请用默认类别管理较对!(亿kWh,万kWh,万人)"); this.Close(); return; } } row8["y" + j] = sum10; if (sum1 != 0) { if (AYdlUnits.Contains("亿") && GDPUnits.Contains("亿元"))//亿kWh 亿元 { sum11 = sum4 * 10000 / sum1;//单产耗能 } else if (AYdlUnits.Contains("万") && GDPUnits.Contains("亿元"))//万kWh 亿元 { sum11 = sum4 / sum1;//单产耗能 } else { MessageBox.Show("全社会用电量或全地区GDP的单位错误!请用默认类别管理较对!(亿kWh,万kWh,亿元)"); this.Close(); return; } } row9["y" + j] = sum11;//单产耗能 if (rows8.Length > 0) { try { sum12 = Convert.ToDouble(rows8[0]["y" + j]); } catch { } row11["y" + j] = sum12; if (sum9 != 0) { if (AYdlUnits.Contains("亿") && NMARkUnits.Contains("万人"))//亿kWh 万人 { sum13 = sum12 * 10000 / sum9;//居民用电 } else if (AYdlUnits.Contains("万") && NMARkUnits.Contains("万人"))//万kWh 万人 { sum13 = sum12 / sum9;//居民用电 } else { MessageBox.Show("全社会用电量或年末总人口的单位错误!请用默认类别管理较对!(亿kWh,万kWh,万人)"); this.Close(); return; } } row10["y" + j] = sum13; } else { row10["y" + j] = sum13; } m++; } dt.Rows.Add(row); for (int k = 0; k < rows3.Length; k++) { double su1 = 0; double su2 = 0; double su3 = 0; DataRow ro1 = dt.NewRow(); ro1["ID"] = Guid.NewGuid().ToString(); ro1["Title"] = rows3[k]["Title"].ToString(); DataRow ro2 = dt.NewRow(); ro2["ID"] = Guid.NewGuid().ToString(); ro2["Title"] = "比例(%)"; for (int j = firstyear; j <= endyear; j++) { if (shjjbyyear) { if (!ht.ContainsValue(j)) continue; } try { su1 = Convert.ToDouble(rows1[0]["y" + j]); } catch { } su2 = 0; su3 = 0; try { su2 = Convert.ToDouble(rows3[k]["y" + j]); } catch { } ro1["y" + j] = su2; if (su1 != 0) su3 = su2 * 100 / su1; ro2["y" + j] = su3; } dt.Rows.Add(ro1); dt.Rows.Add(ro2); } row3["ID"] = Guid.NewGuid().ToString(); row3["Title"] = "地区生产总值增长率(%)"; dt.Rows.Add(row3); row4["ID"] = Guid.NewGuid().ToString(); row4["Title"] = "二、全社会用电量(" + AYdlUnits + ")"; dt.Rows.Add(row4); //row5["ID"] = Guid.NewGuid().ToString(); //row5["Title"] = "最大负荷(万千瓦)"; //dt.Rows.Add(row5); //row6["ID"] = Guid.NewGuid().ToString(); //row6["Title"] = "最大负荷利用小时数(小时)"; //dt.Rows.Add(row6); for (int k = 0; k < rows6.Length; k++) { double su1 = 0; double su2 = 0; double su3 = 0; DataRow ro1 = dt.NewRow(); ro1["ID"] = Guid.NewGuid().ToString(); ro1["Title"] = rows6[k]["Title"].ToString(); DataRow ro2 = dt.NewRow(); ro2["ID"] = Guid.NewGuid().ToString(); ro2["Title"] = "比例(%)"; for (int j = firstyear; j <= endyear; j++) { if (shjjbyyear) { if (!ht.ContainsValue(j)) continue; } try { su1 = Convert.ToDouble(rows4[0]["y" + j]); } catch { } su2 = 0; su3 = 0; try { su2 = Convert.ToDouble(rows6[k]["y" + j]); } catch { } ro1["y" + j] = su2; if (su1 != 0) su3 = su2 * 100 / su1; ro2["y" + j] = su3; } dt.Rows.Add(ro1); dt.Rows.Add(ro2); } row7["ID"] = Guid.NewGuid().ToString(); row7["Title"] = "弹性系数"; dt.Rows.Add(row7); row8["ID"] = Guid.NewGuid().ToString(); row8["Title"] = "人均用电量(千瓦时/人)"; dt.Rows.Add(row8); row9["ID"] = Guid.NewGuid().ToString(); row9["Title"] = "GDP单耗(千瓦时/万元)"; dt.Rows.Add(row9); for (int k = 0; k < rows6.Length; k++) { double su1 = 0; double su2 = 0; double su3 = 0; DataRow ro1 = dt.NewRow(); ro1["ID"] = Guid.NewGuid().ToString(); ro1["Title"] = rows6[k]["Title"].ToString(); for (int j = firstyear; j <= endyear; j++) { if (shjjbyyear) { if (!ht.ContainsValue(j)) continue; } su1 = 0; su2 = 0; su3 = 0; try { su1 = Convert.ToDouble(rows6[k]["y" + j]); } catch { } try { su2 = Convert.ToDouble(rows3[k]["y" + j]); } catch { } if (su2 != 0) { su3 = su1 * 10000 / su2; } else su3 = su1; ro1["y" + j] = su3; } if (rows6[k]["Title"].ToString().IndexOf("居民") >= 0) continue; dt.Rows.Add(ro1); } row10["ID"] = Guid.NewGuid().ToString(); row10["Title"] = "居民用电(千瓦时/人)"; dt.Rows.Add(row10); double d = 0; foreach (DataRow drw1 in dt.Rows) { try { d = (double)drw1["y" + RealFistYear]; } catch { } foreach (DataColumn dc in dt.Columns) { if (dc.ColumnName.IndexOf("m") >= 0) { string s = dc.ColumnName.Replace("m", ""); int y1 = int.Parse(s); double d1 = 0; try { d1 = (double)drw1["y" + s]; } catch { } double sss = Math.Round(Math.Pow(d1 / d, 1.0 / (y1 - RealFistYear)) - 1, 4); if (sss.ToString() == "非数字") sss = 0; drw1["m" + s] = sss; } } } if (!shjjbyyear) { creatsheetbydt(title, dt, viscol); } else { recreatsheetbydt(title, dt, viscol, 2); } }
private System.Data.DataTable getfqgdsjtable() { System.Data.DataTable dataTable = new System.Data.DataTable(); //获得datatable int type = 4; string type1 = "4"; ArrayList al = new ArrayList(); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = type; psp_Type.Col4 = ProjectUID; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); for (int c = 0; c < al.Count; c++) { bool bl = true; foreach (Ps_History ph in listTypes) { if (al[c].ToString() == ph.Title) bl = false; } if (bl) { Ps_History pf = new Ps_History(); pf.ID = Guid.NewGuid().ToString() + "|" + ProjectUID; pf.Forecast = type; pf.ForecastID = type1; pf.Title = al[c].ToString(); pf.Col4 = ProjectUID; object obj = Services.BaseService.GetObject("SelectPs_HistoryMaxID", pf); if (obj != null) pf.Sort = ((int)obj) + 1; else pf.Sort = 1; Services.BaseService.Create<Ps_History>(pf); listTypes.Add(pf); } } dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); return dataTable; }
//形成基础数据电力发展实绩历年地区生产 private void build_dlhistoryGDP() { Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>(); string title = "电力发展实绩_历年地区生产总值"; Ps_YearRange py = new Ps_YearRange(); py.Col4 = "电力发展实绩"; py.Col5 = Itop.Client.MIS.ProgUID; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); int firstyear, endyear; if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 2000; endyear = 2008; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Year"); viscol["Year"] = new Columqk("年份", 3, 2); dt.Columns.Add("GDP", typeof(double)); viscol["GDP"] = new Columqk("GDP(亿元)", 2, 2); dt.Columns.Add("A", typeof(double)); viscol["A"] = new Columqk("增长指数", 2, 2); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = 1; psp_Type.Col4 = Itop.Client.MIS.ProgUID; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); System.Data.DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'"); DataRow[] rows2 = dataTable.Select("Title like '年末总人口%'"); //找不到数据时给出提示 if (rows1.Length == 0 || rows2.Length == 0) { MessageBox.Show("缺少‘全地区GDP’或‘年末总人口’ 数据,无法进行统计!"); this.Close(); return; } string pid = rows1[0]["ID"].ToString(); DataRow[] rows3 = dataTable.Select("ParentID='" + pid + "'"); int m = -1; for (int k = 0; k < rows3.Length; k++) { m++; dt.Columns.Add("m" + m, typeof(double)); dt.Columns.Add("n" + m, typeof(double)); viscol["m" + m] = new Columqk(rows3[k]["Title"].ToString(), 2, 2); viscol["n" + m] = new Columqk("比例(%)", 1, 2); } viscol["RK"] = new Columqk("人口(万人)", 2, 2); viscol["RJGDP"] = new Columqk("人均GDP(万元/人)", 1, 2); dt.Columns.Add("RK", typeof(double)); dt.Columns.Add("RJGDP", typeof(double)); double sum1 = 0; for (int i = firstyear; i <= endyear; i++) { //if (!ht.ContainsValue(i)) // continue; DataRow row = dt.NewRow(); row["ID"] = Guid.NewGuid().ToString(); row["Year"] = i; double sum = 0; try { sum = Convert.ToDouble(rows1[0]["y" + i]); } catch { } row["GDP"] = sum.ToString(); if (i == firstyear) sum1 = sum; if (sum1 != 0) sum1 = sum * 100 / sum1; row["A"] = sum1.ToString("n2"); sum1 = sum; for (int j = 0; j <= m; j++) { double s = 0; double y = 0; try { s = Convert.ToDouble(rows3[j]["y" + i]); } catch { } row["m" + j] = s.ToString(); if (sum != 0) y = s * 100 / sum; row["n" + j] = detel_jd(y, 2); } double rk = 0; double rjgdp = 0; try { rk = Convert.ToDouble(rows2[0]["y" + i]); } catch { } row["RK"] = rk.ToString(); if (rk != 0) rjgdp = sum / rk; row["RJGDP"] = detel_jd(rjgdp, 4); dt.Rows.Add(row); } if (!shjjbyyear) { creatsheetbydt(title, dt, viscol); } else { recreatsheetbydt(title, dt, viscol, 0); } }
//电力发展实绩分行业统计 private void build_dlhistoryfhy() { Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>(); string title = "电力发展实绩_分行业统计"; Ps_YearRange py = new Ps_YearRange(); py.Col4 = "电力发展实绩"; py.Col5 = Itop.Client.MIS.ProgUID; int firstyear, endyear; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 2000; endyear = 2008; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); viscol["Title"] = new Columqk("标题", 3, 2); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = 1; psp_Type.Col4 = Itop.Client.MIS.ProgUID; IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); System.Data.DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); DataRow[] rows1 = dataTable.Select("Title like '全社会用电量%'"); if (rows1.Length == 0) { MessageBox.Show("缺少‘全社会用电量’ 数据,无法进行统计!"); this.Close(); return; } string pid = rows1[0]["ID"].ToString(); string tempTite = rows1[0]["Title"].ToString(); //取出标题中的单位 string Untis = fpcommon.FindUnits(tempTite); DataRow[] rows3 = dataTable.Select("ParentID='" + pid + "'"); if (rows3.Length == 0) { MessageBox.Show("缺少‘全社会用电量’下的分行业用电数据,无法进行统计!"); this.Close(); return; } int m = -1; for (int i = firstyear; i <= endyear; i++) { //if (!ht.ContainsValue(i)) // continue; m++; dt.Columns.Add("y" + i, typeof(double)); dt.Columns.Add("n" + i, typeof(double)); viscol["n" + i] = new Columqk(i + "年百分比", 1, 2); if (Untis.Length > 0) { viscol["y" + i] = new Columqk(i + "年" + "用电量(" + Untis + ")", 2, 2); } else { viscol["y" + i] = new Columqk(i + "年" + "用电量", 2, 2); } } double sum = 0; try { sum = Convert.ToDouble(rows1[0]["y" + firstyear]); } catch { } DataRow row1 = dt.NewRow(); row1["ID"] = Guid.NewGuid().ToString(); row1["Title"] = "用电量总计";//rows1[0]["Title"].ToString(); for (int k = 0; k < rows3.Length; k++) { DataRow row = dt.NewRow(); row["ID"] = Guid.NewGuid().ToString(); row["Title"] = rows3[k]["Title"].ToString(); for (int j = firstyear; j <= endyear; j++) { //if (!ht.ContainsValue(j)) // continue; sum = 0; try { sum = Convert.ToDouble(rows1[0]["y" + j]); } catch { } row1["y" + j] = sum; row1["n" + j] = 1; double sum1 = 0; double sum2 = 0; try { sum1 = Convert.ToDouble(rows3[k]["y" + j]); } catch { } row["y" + j] = sum1; if (sum != 0) sum2 = sum1 / sum; row["n" + j] = sum2; } dt.Rows.Add(row); } dt.Rows.Add(row1); if (!shjjbyyear) { creatsheetbydt(title, dt, viscol); } else { recreatsheetbydt(title, dt, viscol, 1); } }
/// <summary> /// 查询当前数据 /// </summary> /// <param name="FB"></param> /// <param name="CurrentYear"></param> /// <param name="RowTitle"></param> private object SelectCurrentData(Itop.Client.Base.FormBase FB, string CurrentYear, string RowTitle, Ps_History ps1, Ps_History ps2, Ps_History ps3) { string sql = null; object value = 0; string strTemp = "y" + CurrentYear; Ps_History ph=null; if (RowTitle == "全社会用电总计") { RowTitle = "全社会用电量(亿kWh)"; } if (RowTitle == "全行业用电合计" || RowTitle == "居民生活用电合计") { sql = " select " + strTemp + " from ps_History where Title='" + RowTitle + "' and col4='" + FB.ProjectUID + "' and ParentID='"+ps1.ID+"'"; } else if (RowTitle == "第一产业" || RowTitle == "第二产业" || RowTitle == "第三产业") { sql = " select " + strTemp + " from ps_History where Title='" + RowTitle + "' and col4='" + FB.ProjectUID + "' and ParentID='" + ps2.ID + "'"; } else if (RowTitle == "农、林、牧、渔业" || RowTitle == "工业" || RowTitle == "建筑业" || RowTitle == "交通运输、仓储、邮政业" || RowTitle == "信息传输、计算机服务和软件业" || RowTitle == "商业、住宿和餐饮业" || RowTitle == "金融、房地产、商务及居民服务业" || RowTitle == "公共事业及管理组织") { sql = " select " + strTemp + " from ps_History where Title='" + RowTitle + "' and col4='" + FB.ProjectUID + "' and ParentID='" + ps3.ID + "'"; } else { sql = " select " + strTemp + " from ps_History where Title='" + RowTitle + "' and col4='" + FB.ProjectUID + "'"; } try { value = (double)Services.BaseService.GetObject("SelectPs_HistoryPopulationByCondition", sql); } catch (Exception e) { MessageBox.Show("错误,错误原因:" + e.Message, "提示错误", MessageBoxButtons.OK, MessageBoxIcon.Information); } return value; }
//����GDPֵ private void simpleButton7_Click(object sender, EventArgs e) { FormSetGDP frm = new FormSetGDP(); frm.forecastReport = forecastReport; frm.Text = "����GDPֵ"; frm.type = type; DataRow[] rowsoldGDP = dataTable.Select("Title like 'ȫ����GDP%'"); if (frm.ShowDialog() == DialogResult.OK) { if (frm.GetGDP) { //��ȡGDP��ʷֵ if (rowsoldGDP.Length > 0) { DataRow oldrow = rowsoldGDP[0]; //�¾������� 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 dataTable2 = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); DataRow[] rows1 = dataTable2.Select("Title like 'ȫ����GDP%'"); for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++) { double s1 = 0; try { s1 = Convert.ToDouble(rows1[0]["y" + i]); } catch { } oldrow["y" + i] = s1; commonhelp.ResetValue(oldrow["ID"].ToString(), "y" + i); } Ps_Forecast_Math pfm = DataConverter.RowToObject<Ps_Forecast_Math>(oldrow); Services.BaseService.Update<Ps_Forecast_Math>(pfm); } } DataRow[] rowsgdp = dataTable.Select("Title like 'ȫ����GDP%'"); if (rowsgdp.Length > 0) { DataRow oldrow = rowsgdp[0]; Ps_Calc pcs = new Ps_Calc(); pcs.Forecast = type; pcs.ForecastID = forecastReport.ID; IList<Ps_Calc> list1 = Services.BaseService.GetList<Ps_Calc>("SelectPs_CalcByForecast", pcs); Hashtable hs = new Hashtable(); foreach (Ps_Calc pcl1 in list1) { if (!hs.ContainsKey(pcl1.Year)) { hs.Add(pcl1.Year, pcl1.Value2); } } for (int j = forecastReport.YcStartYear; j <= forecastReport.YcEndYear; j++) { double increasenum = double.Parse(hs[j].ToString()); double basenum = double.Parse(oldrow["y" + (j - 1)].ToString()); oldrow["y" + j] = basenum * (1 + increasenum); } Ps_Forecast_Math pfm = DataConverter.RowToObject<Ps_Forecast_Math>(oldrow); Services.BaseService.Update<Ps_Forecast_Math>(pfm); } JS(); } }
/// <summary> /// 显示数据 /// </summary> private void ViewSheet2_1Data(FarPoint.Win.Spread.SheetView obj, string Title, Itop.Client.Base.FormBase FB, int FistYear, int IntRow, int IntCol, string SingleTitle) { string Temp = "y" + FistYear.ToString(); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = IntType; psp_Type.Col4 = FB.ProjectUID; //IList<Ps_History> listTypes = Itop.Client.Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type); //dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History)); // for (int i = 0; i < YearCount ; i++) // { // if (dataTable.Columns[i].Caption == Temp) // MessageBox.Show(listTypes[i]=Temp); // } string con = null; Ps_History GDP1 = null; //if (Title != "年末总人口(万人)" && Title != "城镇化率(%)") //{ if ((Title == "一产") || (Title == "二产") || (Title == "三产") ) { //con = "Title='" + SingleTitle + "'AND Col4='" + FB.ProjectUID + "'AND Forecast='" + IntType + "'"; //GDP1 = (Ps_History)Services.BaseService.GetObject("SelectPs_HistoryByCondition", con); //TwoParentID = GDP1.ID; //if (Title == "一产") //{ // resualt.Add(SingleTitle, GDP1); //} //con = "Title='" + Title + "'AND Col4='" + FB.ProjectUID + "'AND Forecast='" + IntType + "'"; //con += "AND ParentID='" + TwoParentID + "'"; //GDP1 = (Ps_History)Services.BaseService.GetObject("SelectPs_HistoryByCondition", con); //resualt.Add(Title, GDP1); } else { con = "Title='" + Title + "'AND Col4='" + FB.ProjectUID + "'AND Forecast='" + IntType + "'"; GDP1 = (Ps_History)Services.BaseService.GetObject("SelectPs_HistoryByCondition", con); resualt.Add(Title, GDP1); } ////判断是否年份中有数字,没有就不显示 //if (Gethistroyvalue<Ps_History>(resualt[Title], Temp) > 0.0000 || Gethistroyvalue<Ps_History>(resualt[Title], Temp) <0.0000) if (FistYear != 2001 && FistYear != 2002 && FistYear != 2003 && FistYear != 2004) { if ((Title == "一产") || (Title == "二产") || (Title == "三产")) { floatSum[4] = SumTertiaryIndustry(SingleTitle, FB,Temp,Title); obj.SetValue(IntRow, IntCol, ((PF.Gethistroyvalue<Ps_History>(resualt[Title], Temp))/floatSum[4])); } else { obj.SetValue(IntRow, IntCol, PF.Gethistroyvalue<Ps_History>(resualt[Title], Temp)); } } //} }
//�˴�Ϊ��̬������ݷ��� private void Sheet_AddData(FarPoint.Win.Spread.SheetView obj_sheet) { int[] TableYearsAry = TC.GetTableYears(this.GetType().Name); int startrow = 2; int itemlength = 9; string sqlwhere = " ProjectID='" + Tcommon.ProjectID + "'"; IList<PS_Table_AreaWH> ptalist = Services.BaseService.GetList<PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", sqlwhere); //�����趨���� obj_sheet.RowCount = startrow + (ptalist.Count + 1) * itemlength; string sqlwheretemp = " ForecastID='4' and Col4='" + Tcommon.ProjectID + "'"; IList phlisttemp= Services.BaseService.GetList("SelectPs_HistoryBYconnstr", sqlwheretemp); DataTable dttemp = DataConverter.ToDataTable(phlisttemp, typeof(Ps_History)); Ps_History AllRk = new Ps_History(); Ps_History CZrk = new Ps_History(); DataRow RowAllrk = dttemp.NewRow(); ; DataRow RowCZrk = dttemp.NewRow(); RowAllrk = DataConverter.ObjectToRow(AllRk,RowAllrk); RowCZrk = DataConverter.ObjectToRow(CZrk, RowCZrk); for (int i = 0; i < ptalist.Count; i++) { AddItems(obj_sheet, ptalist[i].Title, startrow + i * itemlength); string sqlwhere2 = " ForecastID='4' and Col4='" + Tcommon.ProjectID + "' and Title='" + ptalist[i].Title + "'"; IList<Ps_History> phlist = Services.BaseService.GetList<Ps_History>("SelectPs_HistoryBYconnstr", sqlwhere2); if (phlist.Count > 0) { string sqlwhere3 = " ForecastID='4' and Col4='" + Tcommon.ProjectID + "' and ParentID='" + phlist[0].ID + "'"; IList phlist3 = Services.BaseService.GetList("SelectPs_HistoryBYconnstr", sqlwhere3); DataTable dt = DataConverter.ToDataTable(phlist3, typeof(Ps_History)); DataRow[] rows1 = dt.Select("Title like 'һ��%'"); DataRow[] rows2 = dt.Select("Title like '����%'"); DataRow[] rows3 = dt.Select("Title like '����%'"); DataRow[] rows4 = dt.Select("Title like '�˿�%'"); DataRow[] rows7=null; DataRow[] rows8 = null; if (rows4.Length!=0) { string sqlwhere4 = " ForecastID='4' and Col4='" + Tcommon.ProjectID + "' and ParentID='" + rows4[0]["ID"] + "'"; IList phlist4 = Services.BaseService.GetList("SelectPs_HistoryBYconnstr", sqlwhere4); DataTable dt2 = DataConverter.ToDataTable(phlist4, typeof(Ps_History)); rows7 = dt2.Select("Title like '�����˿�%'"); rows8 = dt2.Select("Title like '����˿�%'"); } DataRow[] rows5 = dt.Select("Title like '�������%'"); DataRow[] rows6 = dt.Select("Title like '���������%'"); //����������ֵ����Ԫ��=һ��+����+���� TC.Sheet_WriteFormula_RowSum(obj_sheet, startrow + i * itemlength + 1, 2, 3, 1, startrow + i * itemlength, 2, TableYearsAry.Length); //�˾�GDP����Ԫ��=����������ֵ����Ԫ��/�˿ڣ� TC.Sheet_WriteFormula_OneRow_AnoterRow_nopercent(obj_sheet, startrow + i * itemlength + 4, 2, startrow + i * itemlength, startrow + i * itemlength + 5, TableYearsAry.Length); for (int j = 0; j < TableYearsAry.Length; j++) { int m = 0; //һ�� string yearstr="y" + TableYearsAry[j].ToString(); m++; if (rows1.Length != 0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, rows1[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "��һ������", "��ѯ ��������ʵ�������Ƿ��и���һ������", ""); } //���� m++; if (rows2.Length != 0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, rows2[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "��������", "��ѯ ��������ʵ�������Ƿ��и�����������", ""); } //���� m++; if (rows3.Length != 0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, rows3[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "����������", "��ѯ ��������ʵ�������Ƿ��и�����������", ""); } //�˿� m++; if (rows4.Length != 0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, rows4[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "���˿�����", "��ѯ ��������ʵ�������Ƿ��и����˿�����", ""); } m++; //���������ƽ��ǧ�ף� m++; if (rows5.Length != 0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, rows5[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "�������������", "��ѯ ��������ʵ�������Ƿ��и��������������", ""); } //�����������ƽ��ǧ�ף� m++; if (rows6.Length != 0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, rows6[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "�������������", "��ѯ ��������ʵ�������Ƿ��и����������������", ""); } //�����ʣ�%�� m++; if (rows7 != null &&rows4.Length!=0) { obj_sheet.SetValue(startrow + i * itemlength + m, 2 + j, Convert.ToDouble(rows7[0][yearstr] )/ Convert.ToDouble(rows4[0][yearstr])); FarPoint.Win.Spread.CellType.PercentCellType newcelltype =new FarPoint.Win.Spread.CellType.PercentCellType(); newcelltype.DecimalPlaces = 2; obj_sheet.Cells[startrow + i * itemlength + m, 2 + j].CellType = newcelltype; RowAllrk[yearstr] = Convert.ToDouble(RowAllrk[yearstr]) + Convert.ToDouble(rows4[0][yearstr]); RowCZrk[yearstr] = Convert.ToDouble(RowCZrk[yearstr]) + Convert.ToDouble(rows7[0][yearstr]); } else { TC.WriteQuestion(title, ptalist[i].Title + "�����˿ڻ����˿�����", "��ѯ ��������ʵ�������Ƿ��и��������˿ڻ����˿�����", ""); } } } } AddItems(obj_sheet, "ȫ��", startrow + ptalist.Count * itemlength); TC.Sheet_WriteFormula_RowSum2(obj_sheet, startrow, 2, ptalist.Count, itemlength, startrow + ptalist.Count * itemlength, 2, 1, 3, TableYearsAry.Length); TC.Sheet_WriteFormula_RowSum2(obj_sheet, startrow, 2, ptalist.Count, itemlength, startrow + ptalist.Count * itemlength, 2, 6, 2, TableYearsAry.Length); //����������ֵ����Ԫ��=һ��+����+���� TC.Sheet_WriteFormula_RowSum(obj_sheet, startrow + ptalist.Count * itemlength+1, 2, 3, 1, startrow + ptalist.Count * itemlength , 2, TableYearsAry.Length); //�˾�GDP����Ԫ��=����������ֵ����Ԫ��/�˿ڣ� TC.Sheet_WriteFormula_OneRow_AnoterRow_nopercent(obj_sheet, startrow + ptalist.Count * itemlength + 4, 2, startrow + ptalist.Count * itemlength, startrow + ptalist.Count * itemlength + 5,TableYearsAry.Length); //�������� for (int k = 0; k < TableYearsAry.Length; k++) { string yearstr = "y" + TableYearsAry[k].ToString(); obj_sheet.SetValue(startrow + ptalist.Count * itemlength + 8, 2 + k, Convert.ToDouble(RowCZrk[yearstr]) / Convert.ToDouble(RowAllrk[yearstr])); FarPoint.Win.Spread.CellType.PercentCellType newcelltype = new FarPoint.Win.Spread.CellType.PercentCellType(); newcelltype.DecimalPlaces = 2; obj_sheet.Cells[startrow + ptalist.Count * itemlength + 8, 2 + k].CellType = newcelltype; } //������ƽ�������� for (int l = 0; l < (ptalist.Count+1)*itemlength; l++) { obj_sheet.Cells[startrow + l, 2 + TableYearsAry.Length].Formula = " Power(R" + (startrow + l + 1) + "C" + (2 + TableYearsAry.Length) + "/R" + (startrow + l + 1) + "C" + 3 + "," + (1.000 / TableYearsAry.Length) + ")-1"; FarPoint.Win.Spread.CellType.PercentCellType newcelltype = new FarPoint.Win.Spread.CellType.PercentCellType(); newcelltype.DecimalPlaces = 2; obj_sheet.Cells[startrow + l, 2 + TableYearsAry.Length].CellType = newcelltype; } }
//���·����õ���� private void RefreshData_FQYD() { //�ı�treelist1�Ľ����㣬Ȼ���ٱ����������treelist1�Ż����ֵ if (treeList1.FocusedNode != null) { TreeListNode node = treeList1.FocusedNode; treeList1.FocusedNode = null; treeList1.FocusedNode = node; } //�������б� AddListID.Clear(); AddList.Clear(); //��ռ����б� ReduceListID.Clear(); ReduceList.Clear(); //��ոı䵥λ�б� changeUnitlist.Clear(); changeUnitlistID.Clear(); AddorReduListBynode(treeList1.Nodes, AddList, ReduceList); if (AddList.Count == 0 && ReduceList.Count == 0 && changeUnitlist.Count == 0) { MsgBox.Show("��δ���κ��ģ�����Ҫ����ģ�飡"); return; } FormHistoryTypeEditDeal frm = new FormHistoryTypeEditDeal(); frm.TypeTitle = "��ȷ�����Ƿ�Ҫ���������ı䣿"; frm.addlist = AddList; frm.reducelist = ReduceList; frm.changeUnitslist = changeUnitlist; if (frm.ShowDialog() == DialogResult.OK) { if (AddListID.Count != 0) { for (int i = 0; i < AddListID.Count; i++) { Ps_HistoryType pht = Common.Services.BaseService.GetOneByKey<Ps_HistoryType>(AddListID[i]); ; Ps_History pf = new Ps_History(); pf.ID = pht.ID + "|" + ProjectID; pf.Forecast = FormFqHistoryDF.Historyhome.type; pf.ForecastID = FormFqHistoryDF.Historyhome.type1; TreeListNode node = treeList1.FindNodeByKeyID(pht.ID); pf.Title = AddList[i].ToString(); if (node.Level==1) { pf.ParentID = ProjectID; } else { pf.ParentID = pht.ParentID + "|" + ProjectID; } pf.Col4 = MIS.ProgUID; //��ʶ��Ĭ��������� pf.Col10 = "1"; pf.Sort = pht.Sort; Ps_History pf2 = new Ps_History(); pf2.ID = pht.ID + "|" + ProjectID + FormFqHistoryDF.Historyhome.splitstr; pf2.Forecast = FormFqHistoryDF.Historyhome.type32; pf2.ForecastID = FormFqHistoryDF.Historyhome.type31; pf2.Title = AddList[i].ToString(); if (pf2.Title.Contains("�õ���")) { pf2.Title = pf2.Title.Replace("�õ���", "����"); } if (pf2.Title.Contains("����")) { pf2.Title=pf2.Title.Replace("����", "����"); } if (pf.Title.Contains("����")) { pf.Title = pf.Title.Replace("����", "����"); } if (node.Level == 1) { pf2.ParentID = ProjectID + FormFqHistoryDF.Historyhome.splitstr; } else { pf2.ParentID = pht.ParentID + "|" + ProjectID + FormFqHistoryDF.Historyhome.splitstr; ; } pf2.Col4 = MIS.ProgUID; //��ʶ��Ĭ��������� pf2.Col10 = "1"; pf2.Sort = pht.Sort; if (pf2.Title.Contains("ͬʱ��")) { pf2.Sort = 0; pf.Sort = 1; for (int j = 1990; j <= 2060; j++) { string y = "y" + j.ToString(); pf2.GetType().GetProperty(y).SetValue(pf2, 1.0, null); pf.GetType().GetProperty(y).SetValue(pf, 1, null); } } try { Common.Services.BaseService.Create<Ps_History>(pf); Common.Services.BaseService.Create<Ps_History>(pf2); FormFqHistoryDF.Historyhome.dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(pf, FormFqHistoryDF.Historyhome.dataTable.NewRow())); FormFqHistoryDF.Historyhome.dataTable2.Rows.Add(Itop.Common.DataConverter.ObjectToRow(pf2, FormFqHistoryDF.Historyhome.dataTable2.NewRow())); } catch (Exception ex) { MsgBox.Show("���ӷ�������" + ex.Message); } } } if (ReduceListID.Count != 0) { for (int i = 0; i < ReduceListID.Count; i++) { TreeListNode node = FormFqHistoryDF.Historyhome.treeList1.FindNodeByKeyID(ReduceListID[i].ToString() + "|" + ProjectID); if (node != null) { FormFqHistoryDF.Historyhome.DeleteNode(node); } TreeListNode node2 = FormFqHistoryDF.Historyhome.treeList2.FindNodeByKeyID(ReduceListID[i].ToString() + "|" + ProjectID + FormFqHistoryDF.Historyhome.splitstr); if (node2 != null) { FormFqHistoryDF.Historyhome.DeleteNode(node2); } } } if (changeUnitlistID.Count != 0) { for (int i = 0; i < changeUnitlistID.Count; i++) { try { Ps_History pht = Common.Services.BaseService.GetOneByKey<Ps_History>(changeUnitlistID[i] + "|" + ProjectID); pht.Title = changeUnitlist[i].ToString(); Common.Services.BaseService.Update<Ps_History>(pht); TreeListNode node = FormFqHistoryDF.Historyhome.treeList1.FindNodeByKeyID(changeUnitlistID[i].ToString() + "|" + ProjectID); if (node != null) { node["Title"] = changeUnitlist[i].ToString(); } Ps_History pht2 = Common.Services.BaseService.GetOneByKey<Ps_History>(changeUnitlistID[i] + "|" + ProjectID + FormFqHistoryDF.Historyhome.splitstr); pht2.Title = changeUnitlist[i].ToString(); if (pht2.Title.Contains("�õ���")) { pht2.Title = pht2.Title.Replace("�õ���", "����"); } if (pht2.Title.Contains("����")) { pht2.Title = pht2.Title.Replace("����", "����"); } Common.Services.BaseService.Update<Ps_History>(pht2); TreeListNode node2 = FormFqHistoryDF.Historyhome.treeList1.FindNodeByKeyID(changeUnitlistID[i].ToString() + "|" + ProjectID + FormFqHistoryDF.Historyhome.splitstr); if (node2 != null) { node2["Title"] = pht2.Title; } } catch (Exception ex) { MsgBox.Show("�ĵ�λ�����" + ex.Message); } } } FormFqHistoryDF.Historyhome.treeList1.Refresh(); FormFqHistoryDF.Historyhome.treeList2.Refresh(); EqueValueBynode(treeList1.Nodes); treeList1.Refresh(); MsgBox.Show("�������!"); } }
private void InitData() { Ps_YearRange py = new Ps_YearRange(); py.Col4 = yearflag; py.Col5 = projectUID; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 2000; endyear = 2008; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = pstype; psp_Type.Col4 = projectUID; 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 'ȫ����õ���%'"); if (rows1.Length==0) { MessageBox.Show("ȱ�١�ȫ����õ����� ����,������ͳ��!"); this.Close(); return; } string pid = rows1[0]["ID"].ToString(); string tempTite=rows1[0]["Title"].ToString(); //ȡ�������еĵ�λ Untis = Historytool.FindUnits(tempTite); DataRow[] rows3 = dataTable.Select("ParentID='"+pid+"'"); if (rows3.Length==0) { MessageBox.Show("ȱ�١�ȫ����õ������µķ���ҵ�õ�����,������ͳ��!"); this.Close(); return; } int m=-1; for (int i = firstyear; i <= endyear; i++) { if (!ht.ContainsValue(i)) continue; m++; dt.Columns.Add("y" + i, typeof(double)); dt.Columns.Add("n" + i, typeof(double)); GridBand gb = new GridBand(); gb.Caption = i + "��"; gb.AppearanceHeader.Options.UseTextOptions = true; gb.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; this.bandedGridView1.Bands.Add(gb); GridBand gb1 = new GridBand(); if (Untis.Length>0) { gb1.Caption = "�õ���("+Untis+")"; } else { gb1.Caption = "�õ���"; } gb1.AppearanceHeader.Options.UseTextOptions = true; gb1.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gb.Children.Add(gb1); GridBand gb2 = new GridBand(); gb2.Caption = "�ٷֱ�"; gb2.AppearanceHeader.Options.UseTextOptions = true; gb2.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gb.Children.Add(gb2); BandedGridColumn gridColumn = new BandedGridColumn(); gridColumn.Caption = i+"���õ���"; gridColumn.FieldName = "y" + i; gridColumn.Visible = true; gridColumn.VisibleIndex = 2*m+10; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridColumn.Width = 95; gb1.Columns.Add(gridColumn); BandedGridColumn gridColumn1 = new BandedGridColumn(); gridColumn1.Caption = i+"��ٷֱ�"; gridColumn1.FieldName = "n" + i; gridColumn1.Visible = true; gridColumn1.VisibleIndex = 2 * m + 11; gridColumn1.DisplayFormat.FormatString = "n2"; gridColumn1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridColumn1.Width = 80; gb2.Columns.Add(gridColumn1); } double sum = 0; try { sum = Convert.ToDouble(rows1[0]["y" + firstyear]); } catch { } DataRow row1 = dt.NewRow(); row1["ID"] = Guid.NewGuid().ToString(); row1["Title"] = "�õ����ܼ�";//rows1[0]["Title"].ToString(); for (int k = 0; k < rows3.Length; k++) { DataRow row = dt.NewRow(); row["ID"] = Guid.NewGuid().ToString(); row["Title"] = rows3[k]["Title"].ToString(); for (int j = firstyear; j <= endyear; j++) { if (!ht.ContainsValue(j)) continue; sum = 0; try { sum = Convert.ToDouble(rows1[0]["y" + j]); } catch { } row1["y" + j] = sum; row1["n" + j] = 1; double sum1 = 0; double sum2 = 0; try { sum1 = Convert.ToDouble(rows3[k]["y" + j]); } catch { } row["y" + j] = sum1; if (sum != 0) sum2 = sum1 / sum; row["n" + j] = sum2; } dt.Rows.Add(row); } dt.Rows.Add(row1); this.gridControl1.DataSource = dt; }
private void InitData() { Ps_YearRange py = new Ps_YearRange(); py.Col4 = yearflag; py.Col5 = projectUID; IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py); if (li.Count > 0) { firstyear = li[0].StartYear; endyear = li[0].FinishYear; } else { firstyear = 2000; endyear = 2008; py.BeginYear = 1990; py.FinishYear = endyear; py.StartYear = firstyear; py.EndYear = 2060; py.ID = Guid.NewGuid().ToString(); Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py); } DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Year"); dt.Columns.Add("GDP", typeof(double)); dt.Columns.Add("A", typeof(double)); Ps_History psp_Type = new Ps_History(); psp_Type.Forecast = pstype; psp_Type.Col4 = projectUID; 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%'"); DataRow[] rows2 = dataTable.Select("Title like '��ĩ���˿�%'"); //�Ҳ�������ʱ������ʾ if (rows1.Length == 0 || rows2.Length == 0) { MessageBox.Show("ȱ�١�ȫ����GDP������ĩ���˿ڡ� ����,������ͳ��!"); this.Close(); return; } string pid = rows1[0]["ID"].ToString(); DataRow[] rows3 = dataTable.Select("ParentID='"+pid+"'"); int m=-1; for(int k=0;k<rows3.Length;k++) { m++; dt.Columns.Add("m" + m, typeof(double)); dt.Columns.Add("n" + m, typeof(double)); GridColumn gridColumn = new GridColumn(); gridColumn.Caption = rows3[k]["Title"].ToString(); gridColumn.FieldName = "m" + m; gridColumn.Visible = true; gridColumn.VisibleIndex = 2*m+10; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridColumn.Width = 70; this.gridView1.Columns.Add(gridColumn); GridColumn gridColumn1 = new GridColumn(); gridColumn1.Caption = "����(%)"; gridColumn1.FieldName = "n" + m; gridColumn1.Visible = true; gridColumn1.VisibleIndex = 2 * m + 11; gridColumn1.DisplayFormat.FormatString = "n0"; gridColumn1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridColumn1.Width = 80; this.gridView1.Columns.Add(gridColumn1); } GridColumn gridColumn2 = new GridColumn(); gridColumn2.Caption = "�˿�(����)"; gridColumn2.FieldName = "RK"; gridColumn2.Visible = true; gridColumn2.VisibleIndex = 2 * m+12; gridColumn2.DisplayFormat.FormatString = "n2"; gridColumn2.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridColumn2.Width = 90; dt.Columns.Add("RK", typeof(double)); this.gridView1.Columns.Add(gridColumn2); GridColumn gridColumn3 = new GridColumn(); gridColumn3.Caption = "�˾�GDP����Ԫ/�ˣ�"; gridColumn3.FieldName = "RJGDP"; gridColumn3.Visible = true; gridColumn3.VisibleIndex = 2 * m + 13; gridColumn3.DisplayFormat.FormatString = "n4"; gridColumn3.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; gridColumn3.Width = 120; dt.Columns.Add("RJGDP", typeof(double)); this.gridView1.Columns.Add(gridColumn3); double sum1 = 0; for (int i = firstyear; i <= endyear; i++) { if(!ht.ContainsValue(i)) continue; DataRow row = dt.NewRow(); row["ID"] = Guid.NewGuid().ToString(); row["Year"] = i; double sum = 0; try { sum = Convert.ToDouble(rows1[0]["y" + i]); } catch { } row["GDP"] = sum.ToString(); if (i == firstyear) sum1 = sum; if (sum1 != 0) sum1 = sum * 100 / sum1; row["A"] = sum1.ToString("n2"); sum1 = sum; for (int j = 0; j <= m; j++) { double s = 0; double y = 0; try { s = Convert.ToDouble(rows3[j]["y" + i]); } catch { } row["m" + j] = s.ToString(); if (sum != 0) y = s*100 / sum; row["n" + j] =detel_jd(y,2); } double rk = 0; double rjgdp = 0; try { rk = Convert.ToDouble(rows2[0]["y" + i]); } catch { } row["RK"] = rk.ToString(); if (rk != 0) rjgdp = sum / rk; row["RJGDP"] = detel_jd(rjgdp, 4); dt.Rows.Add(row); } this.gridControl1.DataSource = dt; }