using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for Class2
/// </summary>
public class DHWZ_Fun
{
    public DHWZ_Fun()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    #region 合并单元格 合并某一行的所有列
    ///　 <summary>　
    ///　 合并GridView中某行相同信息的行（单元格）
    ///　 </summary>　
    ///　 <param　 name="GridView1">GridView对象</param>　
    ///　 <param　 name="cellNum">需要合并的行</param>
    public static void GroupRow(GridView GridView1, int rows)
    {
        TableCell oldTc = GridView1.Rows[rows].Cells[0];
        for (int i = 1; i < GridView1.Rows[rows].Cells.Count; i++)
        {
            TableCell tc = GridView1.Rows[rows].Cells[i];　 //Cells[0]就是你要合并的列
            if (oldTc.Text == tc.Text)
            {
                tc.Visible = false;
                if (oldTc.ColumnSpan == 0)
                {
                    oldTc.ColumnSpan = 1;
                }
                oldTc.ColumnSpan++;
                oldTc.VerticalAlign = VerticalAlign.Middle;
            }
            else
            {
                oldTc = tc;
            }
        }
    }
    #endregion
    #region 合并单元格 合并某一列所有行
    /// <summary>
    /// 合并GridView中某列相同信息的行（单元格）
    /// </summary>
    /// <param name="GridView1"></param>
    /// <param name="cellNum"></param>
    public static void GroupCol(GridView gridView, int cols)
    {
        if (gridView.Rows.Count < 1 || cols > gridView.Rows[0].Cells.Count - 1)
        {
            return;
        }
        TableCell oldTc = gridView.Rows[0].Cells[cols];
        for (int i = 1; i < gridView.Rows.Count; i++)
        {
            TableCell tc = gridView.Rows[i].Cells[cols];
            if (oldTc.Text == tc.Text)
            {
                tc.Visible = false;
                if (oldTc.RowSpan == 0)
                {
                    oldTc.RowSpan = 1;
                }
                oldTc.RowSpan++;
                oldTc.VerticalAlign = VerticalAlign.Middle;
            }
            else
            {
                oldTc = tc;
            }
        }
    }
    #endregion

    public static string getNj(string sz)
    {
        string strReturn = "";
        string myear = System.DateTime.Now.ToString("yyyyMMdd");
        string nW = myear.Substring(2, 2);
        string nE = sz.Substring(2, 2);
        string Mont = myear.Substring(4, 2);
        int k = int.Parse(nW) - int.Parse(nE);
        if (int.Parse(Mont) >= 9)
        {
           
            if (k >= 2)
            {
                strReturn = "9";
            }
            if (k == 1)
            {
                strReturn = "8";
            }
        }
        else
        {
            if (k == 3)
            {
                strReturn = "9";
            }
            if (k == 2)
            {
                strReturn = "8";
            }
            if (k == 1)
            {
                strReturn = "7";
            }
        }



        return strReturn;

    }
}