using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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;
using System.Xml.Linq;
using Microsoft.Office.Interop.Excel;
using System.Data.OleDb;
using System.Reflection;
using System.Threading;
using System.IO;
using System.Collections.Generic;

public partial class 页面集_成绩汇总 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSum_Click(object sender, EventArgs e)
    {
        Schinesone();
        Schinestwo();
        Schinesthree();
        Schinesfour();
        Schinesfive();
        Schinessix();

        Smathone();
        Smathtwo();
        Smaththree();
        Smathfour();
        Smathfive();
        Smathsix();

        Senglishthree();
        Senglishfour();
        Senglishfive();
        Senglishsix();

        Ssciencethree();
        Ssciencefour();
        Ssciencefive();
        Ssciencesix();
    }
    public void Schinesone()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "一年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../语文成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("一年级语文.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../语文成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "一年级成绩汇总表.xls";
                    dt.datauptofileyw(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("一年级语文数据成功传送" + k.ToString() + "次！");
    }
    public void Schinestwo()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "二年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../语文成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("二年级语文.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../语文成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "二年级成绩汇总表.xls";
                    dt.datauptofileyw(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("二年级语文数据成功传送" + k.ToString() + "次！");
    }
    public void Schinesthree()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "三年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../语文成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("三年级语文.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../语文成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "三年级成绩汇总表.xls";
                    dt.datauptofileyw(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("三年级语文数据成功传送" + k.ToString() + "次！");
    }
    public void Schinesfour()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "四年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../语文成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("四年级语文.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../语文成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "四年级成绩汇总表.xls";
                    dt.datauptofileyw(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("四年级语文数据成功传送" + k.ToString() + "次！");
    }
    public void Schinesfive()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "五年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../语文成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("五年级语文.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../语文成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "五年级成绩汇总表.xls";
                    dt.datauptofileyw(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("五年级语文数据成功传送" + k.ToString() + "次！");
    }
    public void Schinessix()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "六年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../语文成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("六年级语文.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../语文成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "六年级成绩汇总表.xls";
                    dt.datauptofileyw(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("六年级语文数据成功传送" + k.ToString() + "次！");
    }

    public void Smathone()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "一年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../数学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("一年级数学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../数学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "一年级成绩汇总表.xls";
                    dt.datauptofileshx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("一年级数学数据成功传送" + k.ToString() + "次！");
    }
    public void Smathtwo()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "二年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../数学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("二年级数学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../数学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "二年级成绩汇总表.xls";
                    dt.datauptofileshx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("二年级数学数据成功传送" + k.ToString() + "次！");
    }
    public void Smaththree()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "三年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../数学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("三年级数学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../数学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "三年级成绩汇总表.xls";
                    dt.datauptofileshx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("三年级数学数据成功传送" + k.ToString() + "次！");
    }
    public void Smathfour()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "四年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../数学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("四年级数学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../数学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "四年级成绩汇总表.xls";
                    dt.datauptofileshx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("四年级数学数据成功传送" + k.ToString() + "次！");
    }
    public void Smathfive()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "五年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../数学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("五年级数学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../数学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "五年级成绩汇总表.xls";
                    dt.datauptofileshx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("五年级数学数据成功传送" + k.ToString() + "次！");
    }
    public void Smathsix()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "六年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../数学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("六年级数学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../数学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "六年级成绩汇总表.xls";
                    dt.datauptofileshx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("六年级数学数据成功传送" + k.ToString() + "次！");
    }
   
    public void Senglishthree()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "三年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../英语成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("三年级英语.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../英语成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "三年级成绩汇总表.xls";
                    dt.datauptofileyy(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("三年级英语数据成功传送" + k.ToString() + "次！");
    }
    public void Senglishfour()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "四年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../英语成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("四年级英语.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../英语成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "四年级成绩汇总表.xls";
                    dt.datauptofileyy(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("四年级英语数据成功传送" + k.ToString() + "次！");
    }
    public void Senglishfive()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "五年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../英语成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("五年级英语.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../英语成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "五年级成绩汇总表.xls";
                    dt.datauptofileyy(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("五年级英语数据成功传送" + k.ToString() + "次！");
    }
    public void Senglishsix()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "六年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../英语成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("六年级英语.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../英语成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "六年级成绩汇总表.xls";
                    dt.datauptofileyy(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("六年级英语数据成功传送" + k.ToString() + "次！");
    }
   
    public void Ssciencethree()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "三年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../科学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("三年级科学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../科学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "三年级成绩汇总表.xls";
                    dt.datauptofilekx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("三年级科学数据成功传送" + k.ToString() + "次！");
    }
    public void Ssciencefour()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "四年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../科学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("四年级科学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../科学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "四年级成绩汇总表.xls";
                    dt.datauptofilekx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("四年级科学数据成功传送" + k.ToString() + "次！");
    }
    public void Ssciencefive()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "五年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../科学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("五年级科学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../科学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "五年级成绩汇总表.xls";
                    dt.datauptofilekx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("五年级科学数据成功传送" + k.ToString() + "次！");
    }
    public void Ssciencesix()
    {
        int k = 0;
        List<string> sheetname = new List<string>();
        OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../") + "汇总表" + "\\" + "六年级成绩汇总表.xls" + ";Extended Properties=Excel 8.0");
        olecon.Open();
        System.Data.DataTable DTable = olecon.GetSchema("Tables");
        DataTableReader DTReader = new DataTableReader(DTable);
        while (DTReader.Read())
        {
            string strName = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();
            if (!sheetname.Contains(strName))
            {
                sheetname.Add(strName);
            }
        }
        DTable = null;
        DTReader = null;
        olecon.Close();
        string path = Server.MapPath("../科学成绩表");
        string[] files = System.IO.Directory.GetFiles(path);
        //string filename = System.IO.Path.GetFileName(newFile);
        DataPost dt = new DataPost();
        foreach (string f in sheetname)
        {
            foreach (string g in files)
            {
                string filename = System.IO.Path.GetFileName(g);
                string fname = filename.Replace("六年级科学.xls", "");
                if (f == fname)
                {
                    string ufilename = Server.MapPath("../科学成绩表") + "\\" + filename;
                    string ofilename = Server.MapPath("../汇总表") + "\\" + "六年级成绩汇总表.xls";
                    dt.datauptofilekx(ufilename, fname, ofilename, f);
                    //Response.Write("数据成功传送！");
                    k++;
                }
            }
        }
        Response.Write("六年级科学数据成功传送" + k.ToString() + "次！");
    }

    protected void btnOne_Click(object sender, EventArgs e)
    {
        //System.Diagnostics.Process.Start(Server.MapPath("./File/一年级成绩汇总表.xls"));
        string path = Server.MapPath("../汇总表/一年级成绩汇总表.xls");
        string name = "一年级成绩汇总表.xls";
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Response.Clear();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
        // 添加头信息，指定文件大小，让浏览器能够显示下载进度
        Response.AddHeader("Content-Length", file.Length.ToString());
        // 指定返回的是一个不能被客户端读取的流，必须被下载
        Response.ContentType = "application/ms-excel";
        // 把文件流发送到客户端
        Response.WriteFile(file.FullName);
        // 停止页面的执行
        //Response.End();     
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    protected void btnTwo_Click(object sender, EventArgs e)
    {
        //System.Diagnostics.Process.Start(Server.MapPath("./File/一年级成绩汇总表.xls"));
        string path = Server.MapPath("../汇总表/二年级成绩汇总表.xls");
        string name = "二年级成绩汇总表.xls";
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Response.Clear();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
        // 添加头信息，指定文件大小，让浏览器能够显示下载进度
        Response.AddHeader("Content-Length", file.Length.ToString());
        // 指定返回的是一个不能被客户端读取的流，必须被下载
        Response.ContentType = "application/ms-excel";
        // 把文件流发送到客户端
        Response.WriteFile(file.FullName);
        // 停止页面的执行
        //Response.End();     
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    protected void btnThree_Click(object sender, EventArgs e)
    {
        //System.Diagnostics.Process.Start(Server.MapPath("./File/一年级成绩汇总表.xls"));
        string path = Server.MapPath("../汇总表/三年级成绩汇总表.xls");
        string name = "三年级成绩汇总表.xls";
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Response.Clear();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
        // 添加头信息，指定文件大小，让浏览器能够显示下载进度
        Response.AddHeader("Content-Length", file.Length.ToString());
        // 指定返回的是一个不能被客户端读取的流，必须被下载
        Response.ContentType = "application/ms-excel";
        // 把文件流发送到客户端
        Response.WriteFile(file.FullName);
        // 停止页面的执行
        //Response.End();     
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    protected void btnFour_Click(object sender, EventArgs e)
    {
        //System.Diagnostics.Process.Start(Server.MapPath("./File/一年级成绩汇总表.xls"));
        string path = Server.MapPath("../汇总表/四年级成绩汇总表.xls");
        string name = "四年级成绩汇总表.xls";
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Response.Clear();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
        // 添加头信息，指定文件大小，让浏览器能够显示下载进度
        Response.AddHeader("Content-Length", file.Length.ToString());
        // 指定返回的是一个不能被客户端读取的流，必须被下载
        Response.ContentType = "application/ms-excel";
        // 把文件流发送到客户端
        Response.WriteFile(file.FullName);
        // 停止页面的执行
        //Response.End();     
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    protected void btnFive_Click(object sender, EventArgs e)
    {
        //System.Diagnostics.Process.Start(Server.MapPath("./File/一年级成绩汇总表.xls"));
        string path = Server.MapPath("../汇总表/五年级成绩汇总表.xls");
        string name = "五年级成绩汇总表.xls";
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Response.Clear();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
        // 添加头信息，指定文件大小，让浏览器能够显示下载进度
        Response.AddHeader("Content-Length", file.Length.ToString());
        // 指定返回的是一个不能被客户端读取的流，必须被下载
        Response.ContentType = "application/ms-excel";
        // 把文件流发送到客户端
        Response.WriteFile(file.FullName);
        // 停止页面的执行
        //Response.End();     
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    protected void btnSix_Click(object sender, EventArgs e)
    {
        //System.Diagnostics.Process.Start(Server.MapPath("./File/一年级成绩汇总表.xls"));
        string path = Server.MapPath("../汇总表/六年级成绩汇总表.xls");
        string name = "六年级成绩汇总表.xls";
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Response.Clear();
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
        // 添加头信息，指定文件大小，让浏览器能够显示下载进度
        Response.AddHeader("Content-Length", file.Length.ToString());
        // 指定返回的是一个不能被客户端读取的流，必须被下载
        Response.ContentType = "application/ms-excel";
        // 把文件流发送到客户端
        Response.WriteFile(file.FullName);
        // 停止页面的执行
        //Response.End();     
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
}
