导入代码文档

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using ERP.BLL;

using mon;

using ERP.Entity;

using System.Data.SqlClient;

using System.Data.OleDb;

using System.Text;

using System.IO;

public partial class ExamManager_RecordWriteIn_BulkPutInExam : BasePage

{

public StringBuilder sqlSB;

public static DataTable objDataTable = new DataTable();

public static DataTable objDT = new DataTable();

public static string savePath = "";

public static DataTable dtC = new DataTable();

public fb_ExamManagerBLL examBLL = new fb_ExamManagerBLL();

protected void Page_Load(object sender, EventArgs e)

{

}

///文件下载

///

///文件的绝对路径

///文件的名字

///

public void DownLoad_File(string filePath, string filename)

{

string strFile = filePath.Replace("\\", "/");

if (!System.IO.File.Exists(strFile))

{

ClientScript.RegisterStartupScript(this.GetType(), "", "");

}

else

{

Response.Clear();

Response.ClearHeaders();

Response.Charset = "GB2312";

Response.ContentEncoding = System.Text.Encoding.UTF8;

Response.ContentType = "application/octet-stream";

FileInfo fi = new FileInfo(strFile);

Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode());

Response.AddHeader("Content-Length", fi.Length.ToString());

byte[] tmpbyte = new byte[1024 * 8];

FileStream fs = fi.OpenRead();

int count;

while ((count = fs.Read(tmpbyte, 0, tmpbyte.Length)) > 0)

{

Response.BinaryWrite(tmpbyte);

Response.Flush();

}

fs.Close();

}

}

protected void LinkButton1_Click(object sender, EventArgs e)

{

DownLoad_File(Server.MapPath(_webRootPath + "/ExamManager/BlukPutInExcel/学员成绩信息.xls"), "学员成绩信息.xls");

}

//导入数据库

protected void Button1_Click(object sender, EventArgs e)

{

//取出文件中的表明,获取带有信息的 DataTable

DataTable dt = new DataTable();

for (int i = 0; i < objDT.Rows.Count; i++)

{

string biaoming = objDT.Rows[i]["TABLE_NAME"].ToString();

dt = getDataSource(savePath, biaoming);

}

/** 导入数据库 **/

ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["SchoolERPDB"];

SqlConnection conn = new SqlConnection(cs.ConnectionString);

try

{

bind();

string ClassC = DDLClass.SelectedValue;

string CoursesC = DDLCourses.SelectedValue;

string GradeC = DDLGrade.SelectedValue;

string ScoresC = DDLScores.SelectedValue;

string SemesterC = DDLSemester.SelectedValue;

string StudentNameC = DDLStudentName.SelectedValue;

string StudentNoC = DDLStudentNo.SelectedValue;

string StudienjahrC = DDLStudienjahr.SelectedValue;

string TypeC = DDLExamType.SelectedValue;

conn.Open();

int colCount = dt.Columns.Count;

int rowCount = dt.Rows.Count;

for (int i = 0; i < rowCount; i++)

{

string className = dt.Rows[i][ClassC].ToString();

string coursesName = dt.Rows[i][CoursesC].ToString();

相关文档
最新文档