Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        private void Calc()
        {
            DataTable dgvDSTable = null;

            // r - range
            //
            DateTime rb = this.ucSelectCondition1.Begin;
            DateTime re = this.ucSelectCondition1.End;
            string stationName = this.ucSelectCondition1.StationName;

            if (re <= rb)
            {
                NUnit.UiKit.UserMessage.DisplayFailure("开始时间必须小于结束时间!");
                return;
            }
            TimeSpan tsUnit = TimeSpan.FromDays(1);
            DateTime b = rb;
            DateTime e = b + tsUnit;
            NN nn = new NN();
            do
            {
                DataTable tbl = CZGRQRCApp.Default.DBI.ExecuteCalcHeat(stationName, b, e);
                // TODO: process day heat
                //
                CalcHeatHelper.AddCalcColumns(tbl, b, nn);
                if (dgvDSTable != null)
                    dgvDSTable.Merge(tbl);
                else
                    dgvDSTable = tbl;
                //this.Merge(dgvDSTable, tbl);
                // next day
                //
                b = e;
                e = e + tsUnit;
                // 与截止日期差一天问题。1-21 ~ 1-24 实际 1-21 ~ 1-23
                //
                //if (e > re)
                //{
                //    e = re;
                //}
                if (e > re)
                {
                    e = re;
                }
                if (b >= re)
                    break;

            }
            while (e <= re);
            this.dataGridView1.DataSource = dgvDSTable;

            this.txtSumHeat.Text = CalcSum(dgvDSTable).ToString("f2");
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tbl"></param>
        public static void AddCalcColumns(DataTable tbl, DateTime begin, NN nn)
        {
            DataColumn c = new DataColumn(DataColumnNames.S1, typeof(int), DataColumnFormulas.S1Diff);
            tbl.Columns.Add(c);

            //c = new DataColumn( DataColumnNames.SupportArea, typeof(float));
            //tbl.Columns.Add(c);
            //FillSupptArea(tbl);

            c = new DataColumn(DataColumnNames.DayRate, typeof(float));
            tbl.Columns.Add(c);
            FillCalcColumns(tbl);

            //string calcHeatFormula = "s1 * (gt1 - bt1) * 4.1868 / dayrate / 1000";
            string calcHeatFormula = Config.Default.CalcHeatFormula;
            c = new DataColumn(DataColumnNames.Heat, typeof(float), calcHeatFormula);
            tbl.Columns.Add(c);

            c = new DataColumn(DataColumnNames.I1, typeof(float), DataColumnFormulas.InstantFluxFormula);
            tbl.Columns.Add(c);

            c = new DataColumn(DataColumnNames.ItemHeat, typeof(float), DataColumnFormulas.ItemHeat);
            tbl.Columns.Add(c);

            //double phTheMonth = CZGRQRCApp.Default.DBI.GetPlanHeat(this.ucCalcHeatCondition1.Begin);
            //int days = GetDaysInMonth(this.ucCalcHeatCondition1.Begin);

            double phTheMonth = CZGRQRCApp.Default.DBI.GetPlanHeat(begin);
            int days = GetDaysInMonth(begin);
            double totalSupportArea = CZGRQRCApp.Default.DBI.GetTotalSupportArea();

            // update month plan heat
            //
            //this.txtMonthPlanHeat.Text = phTheMonth.ToString();
            //this.txtMonthDays.Text = days.ToString();
            //this.txtTotalSupportArea.Text = totalSupportArea.ToString("f2");
            nn.PlanHeatTheMonth = phTheMonth;
            nn.MonthDays = days;
            nn.TotalSupportArea = totalSupportArea;

            string planHeatFormula = string.Format(DataColumnFormulas.PlanHeat,
                //CZGRQRCApp.Default.DBI.GetPlanHeat(this.ucCalcHeatCondition1.Begin),
                phTheMonth,
                totalSupportArea,
                days);
            //this.LastPlanHeatFormula = planHeatFormula;
            nn.LastPlanHeatFormula = planHeatFormula;

            //planHeatFormula = "s1";
            c = new DataColumn(DataColumnNames.PlanHeat, typeof(float), planHeatFormula);
            tbl.Columns.Add(c);
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ucCalcHeatCondition1_OKEvent(object sender, EventArgs e)
        {
            DateTime begin = this.ucCalcHeatCondition1.Begin;
            DateTime end = this.ucCalcHeatCondition1.End;
            DataTable tbl = CZGRQRCApp.Default.DBI.ExecuteCalcHeat(begin, end);

            // move to calcHeatHelper class
            //
            //AddCalcColumns(tbl);
            NN nn = new NN();
            CalcHeatHelper.AddCalcColumns(tbl, this.ucCalcHeatCondition1.Begin, nn);

            // update month plan heat
            //
            this.txtMonthPlanHeat.Text = nn.PlanHeatTheMonth.ToString();
            this.txtMonthDays.Text = nn.MonthDays.ToString();
            this.txtTotalSupportArea.Text = nn.TotalSupportArea.ToString("f2");
            this.LastPlanHeatFormula = nn.LastPlanHeatFormula;

            //FillCalcColumns(tbl);

            StationNameFilter.Default.InitRemoveReplaceNames();
            // remove
            //
            StationNameFilter.Default.RemoveRows(tbl);
            StationNameFilter.Default.ReplaceDisplayNames(tbl);

            EMDataCalculator.Fill(tbl, begin, end);

            this.dataGridView1.DataSource = tbl;
        }