Example #1
0
    /// <summary>
    /// //获取预警详细信息
    /// </summary>
    /// <param name="p">预警类别(1.安全,2.质量,3.成本,4.工期)</param>
    /// <param name="projectType">机构类型(h 总公司;hd 总公司部门;b 分公司;bd 分公司部门;zgxmb 直管项目部;fgsxmb 分公司项目部)</param>
    /// <param name="warnColor">预警颜色</param>
    /// <param name="targetValue">指标值1</param>
    /// <param name="targetValue2">指标值2(成本预警时使用)</param>
    /// <returns></returns>
    private string GetWaringDesc2(int p, string projectType, bool projectHasData, Color warnColor, decimal targetValue, decimal targetValue2)
    {
        string desc = "";

        if (p == 1)
        {
            desc = "安全隐患指数:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%";
        }
        else if (p == 2)
        {
            desc = "日常检查不通过率:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%";
        }
        else if (p == 3)
        {
            if (projectHasData)
            {
                desc = "实际利润率:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,责任上缴比例:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%";
            }
            else
            {
                desc = "【当前机构尚未核算】";
            }
        }
        else if (p == 4)
        {
            desc = "工期延误比例:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%";
        }

        return(desc);
    }
Example #2
0
    //合同摘要
    void LoasdOrder(CurrentProjectInfo projectInfo)
    {
        //if (projectInfo.BeginDate > ClientUtil.ToDateTime("2000-01-01"))
        //{
        //    txtStartDate.Value = projectInfo.BeginDate;
        //}
        //if (projectInfo.EndDate > ClientUtil.ToDateTime("2000-01-01"))
        //{
        //    txtCompleteDate.Value = projectInfo.EndDate;
        //}
        //txtQuanlityTarget.InnerText = projectInfo.QuanlityTarget;//质量目标
        //txtQualityReword.InnerText = projectInfo.QualityReword;//质量奖惩
        //txtSaftyTarget.InnerText = projectInfo.SaftyTarget;//安全目标
        //txtSaftyReword.InnerText = projectInfo.SaftyReword;//安全奖惩
        //txtProReword.InnerText = projectInfo.ProjecRewordt;//工期奖惩

        txtMoneySource.InnerText = EnumUtil <EnumSourcesOfFunding> .GetDescription(projectInfo.SourcesOfFunding);//资金来源

        //txtMoneyStates.SelectedIndex = projectInfo.IsFundsAvailabed;//资金到位情况
        txtProjectCost.InnerText       = UtilityClass.DecimalRound(projectInfo.ProjectCost / 10000, 4);        //工程造价
        txtRealPreMoney.InnerText      = UtilityClass.DecimalRound(projectInfo.RealPerMoney / 10000, 4);       //实际预算总金额
        txtConstractMoney.InnerText    = UtilityClass.DecimalRound(projectInfo.CivilContractMoney / 10000, 4); //土建合同金额
        txtInstallOrderMoney.InnerText = UtilityClass.DecimalRound(projectInfo.InstallOrderMoney / 10000, 4);  //安装合同金额
        txtCollectProport.InnerText    = UtilityClass.DecimalRound(projectInfo.ContractCollectRatio, 4);       //合同收款比例
        txtTurnProport.InnerText       = UtilityClass.DecimalRound(projectInfo.ResProportion, 4);              //责任上缴比例
        txtGroundPrice.InnerText       = UtilityClass.DecimalRound(projectInfo.BigModualGroundUpPrice, 4);
        txtUnderPrice.InnerText        = UtilityClass.DecimalRound(projectInfo.BigModualGroundDownPrice, 4);
        txtExplain.InnerText           = projectInfo.Descript;//备注信息(项目说明)
    }
Example #3
0
    private void BindChart1Data()
    {
        Chart1.Series["Series1"].Points.Clear();
        Chart1.Series["Series2"].Points.Clear();
        Chart1.Series["Series3"].Points.Clear();
        Chart1.Series["Series4"].Points.Clear();

        Random random = new Random();

        string[] times = new string[12];//{ "2012/1", "2012/2", "2012/3", "2012/4", "2012/5", "2012/6","2012/7", "2012/8", "2012/9", "2012/10", "2012/11", "2012/12"};
        int      index = 11;

        for (DateTime i = DateTime.Now; i > DateTime.Now.AddYears(-1); i = i.AddMonths(-1))
        {
            times[index] = i.Year + "/" + i.Month;
            index       -= 1;
        }

        DataTable[] dts = MGWBS.GWBSSrv.GetProjectCostData(DateTime.Now.AddYears(-1), ProjectSyscode);

        //获取起始和结束数据点来设置只有数据点之间的连线
        int firstContractDataIndex           = -1;
        int lastContractDataIndex            = -1;
        int firstResponsibleDataIndex        = -1;
        int lastResponsibleDataIndex         = -1;
        int firstRealDataIndex               = -1;
        int lastRealDataIndex                = -1;
        int firstCollectionsummoneyDataIndex = -1;
        int lastCollectionsummoneyDataIndex  = -1;

        #region 获取起始和结束数据点来设置只有数据点之间的连线
        for (int pointIndex = 0; pointIndex < times.Length; pointIndex++)
        {
            string date = times[pointIndex];
            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
                {
                    if (ClientUtil.ToDecimal(row[1]) != 0)
                    {
                        if (firstContractDataIndex == -1 || firstContractDataIndex > pointIndex)
                        {
                            firstContractDataIndex = pointIndex;
                        }

                        if (lastContractDataIndex == -1 || lastContractDataIndex < pointIndex)
                        {
                            lastContractDataIndex = pointIndex;
                        }
                    }
                    if (ClientUtil.ToDecimal(row[2]) != 0)
                    {
                        if (firstResponsibleDataIndex == -1 || firstResponsibleDataIndex > pointIndex)
                        {
                            firstResponsibleDataIndex = pointIndex;
                        }

                        if (lastResponsibleDataIndex == -1 || lastResponsibleDataIndex < pointIndex)
                        {
                            lastResponsibleDataIndex = pointIndex;
                        }
                    }
                    if (ClientUtil.ToDecimal(row[3]) != 0)
                    {
                        if (firstRealDataIndex == -1 || firstRealDataIndex > pointIndex)
                        {
                            firstRealDataIndex = pointIndex;
                        }

                        if (lastRealDataIndex == -1 || lastRealDataIndex < pointIndex)
                        {
                            lastRealDataIndex = pointIndex;
                        }
                    }
                    break;
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
                {
                    if (ClientUtil.ToDecimal(row[1]) != 0)
                    {
                        if (firstCollectionsummoneyDataIndex == -1 || firstCollectionsummoneyDataIndex > pointIndex)
                        {
                            firstCollectionsummoneyDataIndex = pointIndex;
                        }

                        if (lastCollectionsummoneyDataIndex == -1 || lastCollectionsummoneyDataIndex < pointIndex)
                        {
                            lastCollectionsummoneyDataIndex = pointIndex;
                        }
                    }
                    break;
                }
            }
        }
        #endregion

        #region 加载MSChart图形数据

        for (int pointIndex = 0; pointIndex < times.Length; pointIndex++)
        {
            string  date = times[pointIndex];
            decimal contractTotalPrice     = 0;
            decimal responsibleTotalPrice  = 0;
            decimal realTotalPrice         = 0;
            decimal realCollectionsummoney = 0;//实际收款合同额

            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
                {
                    contractTotalPrice    = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    responsibleTotalPrice = decimal.Round(ClientUtil.ToDecimal(row[2]) / 10000, 2);
                    realTotalPrice        = decimal.Round(ClientUtil.ToDecimal(row[3]) / 10000, 2);
                    break;
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
                {
                    realCollectionsummoney = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    break;
                }
            }

            //Chart1.Series["Series1"].Points.AddXY(date, contractTotalPrice);
            //Chart1.Series["Series2"].Points.AddXY(date, responsibleTotalPrice);
            //Chart1.Series["Series3"].Points.AddXY(date, realTotalPrice);
            //Chart1.Series["Series4"].Points.AddXY(date, realCollectionsummoney);

            //if (DateTime.Parse(date + "-1") == DateTime.Now.Date)
            //    date += "年/月";

            date = date.Substring(2);

            DataPoint dp = new DataPoint();
            dp.AxisLabel  = date;
            dp.LegendText = contractTotalPrice.ToString();
            dp.YValues    = new double[] { (double)contractTotalPrice };
            if (contractTotalPrice != 0 && pointIndex == lastContractDataIndex)
            {
                dp.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstContractDataIndex || pointIndex > lastContractDataIndex)
            if (pointIndex > lastContractDataIndex)
            {
                dp.Color = System.Drawing.Color.Transparent;
            }
            dp.BorderWidth = 2;
            dp.BorderColor = System.Drawing.Color.Red;

            Chart1.Series["Series1"].Points.Add(dp);


            DataPoint dp1 = new DataPoint();
            dp1.AxisLabel  = date;
            dp1.LegendText = responsibleTotalPrice.ToString();
            dp1.YValues    = new double[] { (double)responsibleTotalPrice };
            if (responsibleTotalPrice != 0 && pointIndex == lastResponsibleDataIndex)
            {
                dp1.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstResponsibleDataIndex || pointIndex > lastResponsibleDataIndex)
            if (pointIndex > lastResponsibleDataIndex)
            {
                dp1.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series2"].Points.Add(dp1);

            DataPoint dp2 = new DataPoint();
            dp2.AxisLabel  = date;
            dp2.LegendText = realTotalPrice.ToString();
            dp2.YValues    = new double[] { (double)realTotalPrice };
            if (realTotalPrice != 0 && pointIndex == lastRealDataIndex)
            {
                dp2.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstRealDataIndex || pointIndex > lastRealDataIndex)
            if (pointIndex > lastRealDataIndex)
            {
                dp2.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series3"].Points.Add(dp2);

            DataPoint dp3 = new DataPoint();
            dp3.AxisLabel  = date;
            dp3.LegendText = realCollectionsummoney.ToString();
            dp3.YValues    = new double[] { (double)realCollectionsummoney };
            if (realCollectionsummoney != 0 && pointIndex == lastCollectionsummoneyDataIndex)
            {
                dp3.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstCollectionsummoneyDataIndex || pointIndex > lastCollectionsummoneyDataIndex)
            if (pointIndex > lastCollectionsummoneyDataIndex)
            {
                dp3.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series4"].Points.Add(dp3);
        }
        //Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid..LineColor = System.Drawing.Color.Red;
        //Chart1.Legends[2].ForeColor = System.Drawing.Color.Red;
        #endregion

        #region 加载图形底部说明信息

        List <int> listLastDataIndex = new List <int>();
        listLastDataIndex.Add(lastContractDataIndex);
        listLastDataIndex.Add(lastResponsibleDataIndex);
        listLastDataIndex.Add(lastRealDataIndex);
        listLastDataIndex.Add(lastCollectionsummoneyDataIndex);

        var maxDataIndex = listLastDataIndex.Max(p => p);

        if (maxDataIndex != -1)
        {
            string date = times[maxDataIndex];
            //lblCostInfoTitle.InnerText = date.Replace("/", "年") + "月 成本信息";

            decimal lastContractTotalPrice         = 0;
            decimal lastResonsibleTotalPrice       = 0;
            decimal lastRealTotalPrice             = 0;
            decimal lastColltionsummoneyTotalPrice = 0;

            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
                {
                    lastContractTotalPrice   = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    lastResonsibleTotalPrice = decimal.Round(ClientUtil.ToDecimal(row[2]) / 10000, 2);
                    lastRealTotalPrice       = decimal.Round(ClientUtil.ToDecimal(row[3]) / 10000, 2);
                    break;
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
                {
                    lastColltionsummoneyTotalPrice = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    break;
                }
            }

            //TextAnnotation lblContractTotalPrice = (TextAnnotation)((AnnotationGroup)Chart1.Annotations["lblContractTotalPriceGroup"]).Annotations["lblContractTotalPrice"];
            //TextAnnotation lblResonsibleTotalPrice = (TextAnnotation)((AnnotationGroup)Chart1.Annotations["lblResonsibleTotalPrice"]).Annotations["lblResonsibleTotalPrice"];
            //TextAnnotation lblRealTotalPrice = (TextAnnotation)((AnnotationGroup)Chart1.Annotations["lblRealTotalPrice"]).Annotations["lblRealTotalPrice"];
            //TextAnnotation lblRealColltionsummoney = (TextAnnotation)((AnnotationGroup)Chart1.Annotations["lblRealColltionsummoney"]).Annotations["lblRealColltionsummoney"];
            //TextAnnotation lblProfit = (TextAnnotation)((AnnotationGroup)Chart1.Annotations["lblProfit"]).Annotations["lblProfit"];

            //lblContractTotalPrice.Text = "累计合同收入:" + lastContractTotalPrice.ToString() + " 万元";
            //lblResonsibleTotalPrice.Text = "累计责任成本:" + lastResonsibleTotalPrice.ToString() + " 万元";
            //lblRealTotalPrice.Text = "累计实际成本:" + lastRealTotalPrice.ToString() + " 万元";
            //lblRealColltionsummoney.Text = "累计收款:" + lastColltionsummoneyTotalPrice.ToString() + " 万元";

            //if (lastContractTotalPrice != 0)
            //    lblProfit.Text = "利润率:" + UtilityClass.DecimalRound(((lastContractTotalPrice - lastRealTotalPrice) / lastContractTotalPrice) * 100, 2).ToString() + "%";

            lblContractTotalPrice.InnerText   = lastContractTotalPrice.ToString();
            lblResonsibleTotalPrice.InnerText = lastResonsibleTotalPrice.ToString();
            lblRealTotalPrice.InnerText       = lastRealTotalPrice.ToString();
            lblRealColltionsummoney.InnerText = lastColltionsummoneyTotalPrice.ToString();

            if (lastContractTotalPrice != 0)
            {
                lblProfit.InnerText = UtilityClass.DecimalRound(((lastContractTotalPrice - lastRealTotalPrice) / lastContractTotalPrice) * 100, 2).ToString() + "%";
            }
        }
        #endregion
    }
Example #4
0
    /// <summary>
    /// //获取预警详细信息
    /// </summary>
    /// <param name="p">预警类别(1.安全,2.质量,3.成本,4.工期)</param>
    /// <param name="projectType">机构类型(h 总公司;hd 总公司部门;b 分公司;bd 分公司部门;zgxmb 直管项目部;fgsxmb 分公司项目部)</param>
    /// <param name="warnColor">预警颜色</param>
    /// <param name="targetValue">指标值1</param>
    /// <param name="targetValue2">指标值2(成本预警时使用)</param>
    /// <returns></returns>
    private string GetWaringDesc(int p, string projectType, bool projectHasData, Color warnColor, decimal targetValue, decimal targetValue2)
    {
        string desc = "";

        if (p == 1)
        {
            if (projectType == "h" || projectType == "b")
            {
                if (warnColor == Color.Green)
                {
                    desc = "<label title='安全隐患指数<5%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Yellow)
                {
                    desc = "<label title='5%≤安全隐患指数<20%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Orange)
                {
                    desc = "<label title='20%≤安全隐患指数<40%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else
                {
                    desc = "<label title='40%≤安全隐患指数,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
            }
            else
            {
                if (warnColor == Color.Green)
                {
                    desc = "<label title='安全隐患指数<5%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Yellow)
                {
                    desc = "<label title='5%≤安全隐患指数<15%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Orange)
                {
                    desc = "<label title='15%≤安全隐患指数<30%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else
                {
                    desc = "<label title='30%≤安全隐患指数,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
            }
        }
        else if (p == 2)
        {
            if (projectType == "h" || projectType == "b")
            {
                if (warnColor == Color.Green)
                {
                    desc = "<label title='日常检查不通过指数<5%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Yellow)
                {
                    desc = "<label title='5%≤日常检查不通过指数<20%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Orange)
                {
                    desc = "<label title='20%≤日常检查不通过指数<40%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else
                {
                    desc = "<label title='40%≤日常检查不通过指数,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
            }
            else
            {
                if (warnColor == Color.Green)
                {
                    desc = "<label title='日常检查不通过指数<5%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Yellow)
                {
                    desc = "<label title='5%≤日常检查不通过指数<15%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Orange)
                {
                    desc = "<label title='15%≤日常检查不通过指数<30%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else
                {
                    desc = "<label title='30%≤日常检查不通过指数,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
            }
        }
        else if (p == 3)
        {
            if (projectHasData)
            {
                if (projectType == "h" || projectType == "b")
                {
                    if (warnColor == Color.Green)
                    {
                        desc = "<label title='平均责任上缴比例<实际平均利润率;当前[实际平均利润率]:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,[平均责任上缴比例]:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%'>【判定指标】<label/>";
                    }
                    else if (warnColor == Color.Yellow)
                    {
                        desc = "<label title='0<实际平均利润率≤平均责任上缴比例;当前[实际平均利润率]:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,[平均责任上缴比例]:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%'>【判定指标】<label/>";
                    }
                    else
                    {
                        desc = "<label title='实际平均利润率≤0;当前[实际平均利润率]:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,[平均责任上缴比例]:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%'>【判定指标】<label/>";
                    }
                }
                else
                {
                    if (warnColor == Color.Green)
                    {
                        desc = "<label title='责任上缴比例<实际利润率;当前[实际利润率]:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,[责任上缴比例]:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%'>【判定指标】<label/>";
                    }
                    else if (warnColor == Color.Yellow)
                    {
                        desc = "<label title='0<实际利润率≤责任上缴比例;当前[实际利润率]:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,[责任上缴比例]:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%'>【判定指标】<label/>";
                    }
                    else
                    {
                        desc = "<label title='实际利润率≤0;当前[实际利润率]:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%,[责任上缴比例]:" + UtilityClass.DecimalRound(targetValue2 * 100, 2) + "%'>【判定指标】<label/>";
                    }
                }
            }
            else
            {
                desc = "【当前机构尚未核算】";
            }
        }
        else if (p == 4)
        {
            if (projectType == "h" || projectType == "b")
            {
                if (warnColor == Color.Green)
                {
                    desc = "<label title='任务工期延误比例<5%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Yellow)
                {
                    desc = "<label title='5%≤任务工期延误比例<15%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Orange)
                {
                    desc = "<label title='15%≤任务工期延误比例<30%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else
                {
                    desc = "<label title='30%≤任务工期延误比例,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
            }
            else
            {
                if (warnColor == Color.Green)
                {
                    desc = "<label title='任务工期延误比例<5%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Yellow)
                {
                    desc = "<label title='5%≤任务工期延误比例<15%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else if (warnColor == Color.Orange)
                {
                    desc = "<label title='15%≤任务工期延误比例<30%,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
                else
                {
                    desc = "<label title='30%≤任务工期延误比例,当前值为:" + UtilityClass.DecimalRound(targetValue * 100, 2) + "%'>【判定指标】<label/>";
                }
            }
        }


        return(desc);
    }
Example #5
0
    private void BindChart1Data()
    {
        Chart1.Series["Series1"].Points.Clear();
        //Chart1.Series["Series2"].Points.Clear();
        Chart1.Series["Series3"].Points.Clear();
        Chart1.Series["Series4"].Points.Clear();
        Chart1.Series["Series5"].Points.Clear();
        //Chart1.Series["Series6"].Points.Clear();
        Chart1.Series["Series7"].Points.Clear();
        Chart1.Series["Series8"].Points.Clear();

        string[] times = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" };

        int lastYear = DateTime.Now.Year - 1;
        int thisYear = DateTime.Now.Year;

        Chart1.Series["Series1"].LegendText = lastYear + "合同收入";
        //Chart1.Series["Series2"].LegendText = lastYear + "累计责任成本";
        Chart1.Series["Series3"].LegendText = lastYear + "实际成本";
        Chart1.Series["Series4"].LegendText = lastYear + "实际收款";
        Chart1.Series["Series5"].LegendText = thisYear + "合同收入";
        //Chart1.Series["Series6"].LegendText = thisYear + "累计责任成本";
        Chart1.Series["Series7"].LegendText = thisYear + "实际成本";
        Chart1.Series["Series8"].LegendText = thisYear + "实际收款";

        DataTable[] dts = MGWBS.GWBSSrv.GetProjectCostDataByYear(DateTime.Parse(lastYear + "-1-1"), ProjectSyscode);

        //获取起始和结束数据点来设置只有数据点之间的连线
        int firstContractDataIndex           = -1;
        int lastContractDataIndex            = -1;
        int firstResponsibleDataIndex        = -1;
        int lastResponsibleDataIndex         = -1;
        int firstRealDataIndex               = -1;
        int lastRealDataIndex                = -1;
        int firstCollectionsummoneyDataIndex = -1;
        int lastCollectionsummoneyDataIndex  = -1;

        int firstContractDataIndex2           = -1;
        int lastContractDataIndex2            = -1;
        int firstResponsibleDataIndex2        = -1;
        int lastResponsibleDataIndex2         = -1;
        int firstRealDataIndex2               = -1;
        int lastRealDataIndex2                = -1;
        int firstCollectionsummoneyDataIndex2 = -1;
        int lastCollectionsummoneyDataIndex2  = -1;

        #region 获取起始和结束数据点来设置只有数据点之间的连线
        for (int pointIndex = 0; pointIndex < times.Length; pointIndex++)
        {
            string date = times[pointIndex];
            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(lastYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    if (ClientUtil.ToDecimal(row[1]) != 0)
                    {
                        if (firstContractDataIndex == -1 || firstContractDataIndex > pointIndex)
                        {
                            firstContractDataIndex = pointIndex;
                        }

                        if (lastContractDataIndex == -1 || lastContractDataIndex < pointIndex)
                        {
                            lastContractDataIndex = pointIndex;
                        }
                    }
                    if (ClientUtil.ToDecimal(row[2]) != 0)
                    {
                        if (firstResponsibleDataIndex == -1 || firstResponsibleDataIndex > pointIndex)
                        {
                            firstResponsibleDataIndex = pointIndex;
                        }

                        if (lastResponsibleDataIndex == -1 || lastResponsibleDataIndex < pointIndex)
                        {
                            lastResponsibleDataIndex = pointIndex;
                        }
                    }
                    if (ClientUtil.ToDecimal(row[3]) != 0)
                    {
                        if (firstRealDataIndex == -1 || firstRealDataIndex > pointIndex)
                        {
                            firstRealDataIndex = pointIndex;
                        }

                        if (lastRealDataIndex == -1 || lastRealDataIndex < pointIndex)
                        {
                            lastRealDataIndex = pointIndex;
                        }
                    }
                    break;
                }
                if (DateTime.Parse(thisYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    if (ClientUtil.ToDecimal(row[1]) != 0)
                    {
                        if (firstContractDataIndex2 == -1 || firstContractDataIndex2 > pointIndex)
                        {
                            firstContractDataIndex2 = pointIndex;
                        }

                        if (lastContractDataIndex2 == -1 || lastContractDataIndex2 < pointIndex)
                        {
                            lastContractDataIndex2 = pointIndex;
                        }
                    }
                    if (ClientUtil.ToDecimal(row[2]) != 0)
                    {
                        if (firstResponsibleDataIndex2 == -1 || firstResponsibleDataIndex2 > pointIndex)
                        {
                            firstResponsibleDataIndex2 = pointIndex;
                        }

                        if (lastResponsibleDataIndex2 == -1 || lastResponsibleDataIndex2 < pointIndex)
                        {
                            lastResponsibleDataIndex2 = pointIndex;
                        }
                    }
                    if (ClientUtil.ToDecimal(row[3]) != 0)
                    {
                        if (firstRealDataIndex2 == -1 || firstRealDataIndex2 > pointIndex)
                        {
                            firstRealDataIndex2 = pointIndex;
                        }

                        if (lastRealDataIndex2 == -1 || lastRealDataIndex2 < pointIndex)
                        {
                            lastRealDataIndex2 = pointIndex;
                        }
                    }
                    break;
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(lastYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    if (ClientUtil.ToDecimal(row[1]) != 0)
                    {
                        if (firstCollectionsummoneyDataIndex == -1 || firstCollectionsummoneyDataIndex > pointIndex)
                        {
                            firstCollectionsummoneyDataIndex = pointIndex;
                        }

                        if (lastCollectionsummoneyDataIndex == -1 || lastCollectionsummoneyDataIndex < pointIndex)
                        {
                            lastCollectionsummoneyDataIndex = pointIndex;
                        }
                    }
                    break;
                }
                if (DateTime.Parse(thisYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    if (ClientUtil.ToDecimal(row[1]) != 0)
                    {
                        if (firstCollectionsummoneyDataIndex2 == -1 || firstCollectionsummoneyDataIndex2 > pointIndex)
                        {
                            firstCollectionsummoneyDataIndex2 = pointIndex;
                        }

                        if (lastCollectionsummoneyDataIndex2 == -1 || lastCollectionsummoneyDataIndex2 < pointIndex)
                        {
                            lastCollectionsummoneyDataIndex2 = pointIndex;
                        }
                    }
                    break;
                }
            }
        }
        #endregion

        #region 加载MSChart图形数据
        for (int pointIndex = 0; pointIndex < times.Length; pointIndex++)
        {
            string date = times[pointIndex];

            decimal contractTotalPriceLastYear     = 0;
            decimal responsibleTotalPriceLastYear  = 0;
            decimal realTotalPriceLastYear         = 0;
            decimal realCollectionsummoneyLastYear = 0;//实际收款合同额

            decimal contractTotalPriceThisYear     = 0;
            decimal responsibleTotalPriceThisYear  = 0;
            decimal realTotalPriceThisYear         = 0;
            decimal realCollectionsummoneyThisYear = 0;//实际收款合同额

            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(lastYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    contractTotalPriceLastYear    = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    responsibleTotalPriceLastYear = decimal.Round(ClientUtil.ToDecimal(row[2]) / 10000, 2);
                    realTotalPriceLastYear        = decimal.Round(ClientUtil.ToDecimal(row[3]) / 10000, 2);
                }
                if (DateTime.Parse(thisYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    contractTotalPriceThisYear    = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    responsibleTotalPriceThisYear = decimal.Round(ClientUtil.ToDecimal(row[2]) / 10000, 2);
                    realTotalPriceThisYear        = decimal.Round(ClientUtil.ToDecimal(row[3]) / 10000, 2);
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(lastYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    realCollectionsummoneyLastYear = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                }
                if (DateTime.Parse(thisYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    realCollectionsummoneyThisYear = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                }
            }

            date += "月";

            #region  一年指标

            DataPoint dp = new DataPoint();
            dp.AxisLabel  = date;
            dp.LegendText = contractTotalPriceLastYear.ToString();
            dp.YValues    = new double[] { (double)contractTotalPriceLastYear };
            if (contractTotalPriceLastYear != 0 && pointIndex == lastContractDataIndex)
            {
                dp.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstContractDataIndex || pointIndex > lastContractDataIndex)
            if (pointIndex > lastContractDataIndex)
            {
                dp.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series1"].Points.Add(dp);

            //DataPoint dp1 = new DataPoint();
            //dp1.AxisLabel = date;
            //dp1.LegendText = responsibleTotalPriceLastYear.ToString();
            //dp1.YValues = new double[] { (double)responsibleTotalPriceLastYear };
            //if (responsibleTotalPriceLastYear != 0 && pointIndex == lastResponsibleDataIndex)
            //{
            //    dp1.IsValueShownAsLabel = true;
            //}
            //if (pointIndex <= firstResponsibleDataIndex || pointIndex > lastResponsibleDataIndex)
            //{
            //    dp1.Color = System.Drawing.Color.Transparent;
            //}
            //Chart1.Series["Series2"].Points.Add(dp1);

            DataPoint dp2 = new DataPoint();
            dp2.AxisLabel  = date;
            dp2.LegendText = realTotalPriceLastYear.ToString();
            dp2.YValues    = new double[] { (double)realTotalPriceLastYear };
            if (realTotalPriceLastYear != 0 && pointIndex == lastRealDataIndex)
            {
                dp2.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstRealDataIndex || pointIndex > lastRealDataIndex)
            if (pointIndex > lastRealDataIndex)
            {
                dp2.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series3"].Points.Add(dp2);

            DataPoint dp3 = new DataPoint();
            dp3.AxisLabel  = date;
            dp3.LegendText = realCollectionsummoneyLastYear.ToString();
            dp3.YValues    = new double[] { (double)realCollectionsummoneyLastYear };
            if (realCollectionsummoneyLastYear != 0 && pointIndex == lastCollectionsummoneyDataIndex)
            {
                dp3.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstCollectionsummoneyDataIndex || pointIndex > lastCollectionsummoneyDataIndex)
            if (pointIndex > lastCollectionsummoneyDataIndex)
            {
                dp3.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series4"].Points.Add(dp3);

            #endregion

            #region 今年指标

            DataPoint dp4 = new DataPoint();
            dp4.AxisLabel  = date;
            dp4.LegendText = contractTotalPriceThisYear.ToString();
            dp4.YValues    = new double[] { (double)contractTotalPriceThisYear };
            if (contractTotalPriceThisYear != 0 && pointIndex == lastContractDataIndex2)
            {
                dp4.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstContractDataIndex2 || pointIndex > lastContractDataIndex2)
            if (pointIndex > lastContractDataIndex2)
            {
                dp4.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series5"].Points.Add(dp4);

            //DataPoint dp5 = new DataPoint();
            //dp5.AxisLabel = date;
            //dp5.LegendText = responsibleTotalPriceThisYear.ToString();
            //dp5.YValues = new double[] { (double)responsibleTotalPriceThisYear };
            //if (responsibleTotalPriceThisYear != 0 && pointIndex == lastResponsibleDataIndex2)
            //{
            //    dp5.IsValueShownAsLabel = true;
            //}
            //if (pointIndex <= firstResponsibleDataIndex2 || pointIndex > lastResponsibleDataIndex2)
            //{
            //    dp5.Color = System.Drawing.Color.Transparent;
            //}
            //Chart1.Series["Series6"].Points.Add(dp5);

            DataPoint dp6 = new DataPoint();
            dp6.AxisLabel  = date;
            dp6.LegendText = realTotalPriceThisYear.ToString();
            dp6.YValues    = new double[] { (double)realTotalPriceThisYear };
            if (realTotalPriceThisYear != 0 && pointIndex == lastRealDataIndex2)
            {
                dp6.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstRealDataIndex2 || pointIndex > lastRealDataIndex2)
            if (pointIndex > lastRealDataIndex2)
            {
                dp6.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series7"].Points.Add(dp6);

            DataPoint dp7 = new DataPoint();
            dp7.AxisLabel  = date;
            dp7.LegendText = realCollectionsummoneyThisYear.ToString();
            dp7.YValues    = new double[] { (double)realCollectionsummoneyThisYear };
            if (realCollectionsummoneyThisYear != 0 && pointIndex == lastCollectionsummoneyDataIndex2)
            {
                dp7.IsValueShownAsLabel = true;
            }
            //if (pointIndex <= firstCollectionsummoneyDataIndex2 || pointIndex > lastCollectionsummoneyDataIndex2)
            if (pointIndex > lastCollectionsummoneyDataIndex2)
            {
                dp7.Color = System.Drawing.Color.Transparent;
            }
            Chart1.Series["Series8"].Points.Add(dp7);

            #endregion
        }
        #endregion

        #region 加载图形底部说明信息

        List <int> listLastDataIndex = new List <int>();
        listLastDataIndex.Add(lastContractDataIndex);
        listLastDataIndex.Add(lastResponsibleDataIndex);
        listLastDataIndex.Add(lastRealDataIndex);
        listLastDataIndex.Add(lastCollectionsummoneyDataIndex);

        var maxDataIndex = listLastDataIndex.Max(p => p);

        if (maxDataIndex != -1)
        {
            string date = times[maxDataIndex];
            lblCostInfoTitle.InnerText = lastYear + "年" + date + "月 成本信息";

            decimal lastContractTotalPrice         = 0;
            decimal lastResonsibleTotalPrice       = 0;
            decimal lastRealTotalPrice             = 0;
            decimal lastColltionsummoneyTotalPrice = 0;

            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(lastYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    lastContractTotalPrice   = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    lastResonsibleTotalPrice = decimal.Round(ClientUtil.ToDecimal(row[2]) / 10000, 2);
                    lastRealTotalPrice       = decimal.Round(ClientUtil.ToDecimal(row[3]) / 10000, 2);
                    break;
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(lastYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    lastColltionsummoneyTotalPrice = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    break;
                }
            }

            lblContractTotalPrice.InnerText   = lastContractTotalPrice.ToString();
            lblResonsibleTotalPrice.InnerText = lastResonsibleTotalPrice.ToString();
            lblRealTotalPrice.InnerText       = lastRealTotalPrice.ToString();
            lblRealColltionsummoney.InnerText = lastColltionsummoneyTotalPrice.ToString();

            if (lastContractTotalPrice != 0)
            {
                lblProfit.InnerText = UtilityClass.DecimalRound(((lastContractTotalPrice - lastRealTotalPrice) / lastContractTotalPrice) * 100, 2).ToString() + "%";
            }
        }
        else
        {
            lblCostInfoTitle.InnerText = lastYear + "年--月 成本信息";
        }

        listLastDataIndex.Clear();
        listLastDataIndex.Add(lastContractDataIndex2);
        listLastDataIndex.Add(lastResponsibleDataIndex2);
        listLastDataIndex.Add(lastRealDataIndex2);
        listLastDataIndex.Add(lastCollectionsummoneyDataIndex2);

        maxDataIndex = listLastDataIndex.Max(p => p);

        decimal lastContractTotalPrice2         = 0;
        decimal lastResonsibleTotalPrice2       = 0;
        decimal lastRealTotalPrice2             = 0;
        decimal lastColltionsummoneyTotalPrice2 = 0;
        if (maxDataIndex != -1)
        {
            string date = times[maxDataIndex];
            lblCostInfoTitle2.InnerText = thisYear + "年" + date + "月 成本信息";

            foreach (DataRow row in dts[0].Rows)
            {
                if (DateTime.Parse(thisYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    lastContractTotalPrice2   = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    lastResonsibleTotalPrice2 = decimal.Round(ClientUtil.ToDecimal(row[2]) / 10000, 2);
                    lastRealTotalPrice2       = decimal.Round(ClientUtil.ToDecimal(row[3]) / 10000, 2);
                    break;
                }
            }
            foreach (DataRow row in dts[1].Rows)
            {
                if (DateTime.Parse(thisYear + "-" + date) == DateTime.Parse(row[0].ToString()))
                {
                    lastColltionsummoneyTotalPrice2 = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
                    break;
                }
            }

            lblContractTotalPrice2.InnerText   = lastContractTotalPrice2.ToString();
            lblResonsibleTotalPrice2.InnerText = lastResonsibleTotalPrice2.ToString();
            lblRealTotalPrice2.InnerText       = lastRealTotalPrice2.ToString();
            lblRealColltionsummoney2.InnerText = lastColltionsummoneyTotalPrice2.ToString();

            if (lastContractTotalPrice2 != 0)
            {
                lblProfit2.InnerText = UtilityClass.DecimalRound(((lastContractTotalPrice2 - lastRealTotalPrice2) / lastContractTotalPrice2) * 100, 2).ToString() + "%";
            }
        }
        else
        {
            lblCostInfoTitle2.InnerText = thisYear + "年--月 成本信息";
        }
        #endregion

        //利润分析图
        //DataSet ds = MGWBS.GWBSSrv.GetProjectProfitData(DateTime.Now.AddYears(-1), ProjectSyscode);

        //for (int pointIndex = 0; pointIndex < times.Length; pointIndex++)
        //{
        //    string date = times[pointIndex];
        //    decimal profitTotalPrice = 0;

        //    foreach (DataRow row in ds.Tables[0].Rows)
        //    {
        //        if (DateTime.Parse(date) == DateTime.Parse(row[0].ToString()))
        //        {
        //            profitTotalPrice = decimal.Round(ClientUtil.ToDecimal(row[1]) / 10000, 2);
        //            break;
        //        }
        //    }

        //    Chart1.Series["Series1"].Points.AddXY(date, profitTotalPrice);
        //}
    }