zoukankan      html  css  js  c++  java
  • case

    日期间隔计算
    // Returns the number of days between the current 
    // date/time and hiredDate
    TimeSpan ts = DateTime.Now.Subtract(employee.HireDate);
    return ts.Days.ToString("#,##0");



    //GridView的页脚中显示统计信息
    // 类范围,累积合计的变量……
     2decimal _totalUnitPrice = 0m;
     3int _totalNonNullUnitPriceCount = 0;
     4int _totalUnitsInStock = 0;
     5int _totalUnitsOnOrder = 0;
    protected void ProductsInCategory_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Reference the ProductsRow via the e.Row.DataItem property
                Northwind.ProductsRow product = (Northwind.ProductsRow)((System.Data.DataRowView)e.Row.DataItem).Row;
                //……增加累积合计……
                // Increment the running totals (if they're not NULL!)
                if (!product.IsUnitPriceNull())
                {
                    _totalUnitPrice += product.UnitPrice;
                    _totalNonNullUnitPriceCount++;
                }

                if (!product.IsUnitsInStockNull())
                    _totalUnitsInStock += product.UnitsInStock;

                if (!product.IsUnitsOnOrderNull())
                    _totalUnitsOnOrder += product.UnitsOnOrder;
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                /// 确定平均单价
                decimal avgUnitPrice = _totalUnitPrice / (decimal)_totalNonNullUnitPriceCount;

                //// 在相应的单元格中显示统计数据 Display the summary data in the appropriate cells
                e.Row.Cells[1].Text = "Avg.: " + avgUnitPrice.ToString("c");
                e.Row.Cells[2].Text = "Total: " + _totalUnitsInStock.ToString();
                e.Row.Cells[3].Text = "Total: " + _totalUnitsOnOrder.ToString();
            }
        }

  • 相关阅读:
    iOS Hardware Guide
    安卓上为什么不能用system.io.file读取streammingAssets目录下的文件
    【转】【Unity+Lua】实测如何性能优化(Lua和C#交互篇)
    随手记:IDAPro蛮强大
    断线重连
    稀土掘金
    C#利用WebService接口下载文件
    C# sbyte[]转byte[]
    百度地图API示例 JS
    如何才能成为一个好的技术领导者?
  • 原文地址:https://www.cnblogs.com/zwl12549/p/677577.html
Copyright © 2011-2022 走看看