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

  • 相关阅读:
    python爬虫 关于Max retries exceeded with url 的错误
    爬虫最新的库requestshtml库总结
    adb命令将抓包工具证书从用户目录移动至系统目录,解决反爬对于本地证书认证
    imei码生成
    利用Frida修改Android设备的唯一标识符
    linux下启动selenium爬虫并安装谷歌浏览器和驱动
    JS输出为[object Object] 如何解决
    【转载】Vim 的 tab 设置
    python实现的斐波那契数列
    MySQL设置UTF8字符
  • 原文地址:https://www.cnblogs.com/zwl12549/p/677577.html
Copyright © 2011-2022 走看看