• 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();
            }
        }

  • 相关阅读:
    mysql非安装包安装教程
    HTML和CSS <h1> --3-- <h1>
    HTML和CSS <h1> --2-- <h1>
    HTML和CSS <h1> --1-- <h1>
    软件工程之四则运算总结
    图论算法 有图有代码 万字总结 向前辈致敬
    【万里征程——Windows App开发】使用Toast通知
    【万里征程——Windows App开发】设置共享(共享源和共享目标)
    【万里征程——Windows App开发】如何使用粘贴板
    【万里征程——Windows App开发】在应用中集成搜索
  • 原文地址:https://www.cnblogs.com/zwl12549/p/677577.html
Copyright © 2020-2023  润新知