ImportShouFeiExcel.aspx.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils;
using WebClass;
using System.IO;
public partial class ImportShouFeiExcel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (!FileUpload1.HasFile)
{
Page.AlertThis("请选择上传的文件!");
return;
}
if (!FileUpload1.isFileType("xls", "xlsx"))
{
Page.AlertThis("文件类型不正确!");
return;
}
var dym = Path.GetFileNameWithoutExtension(FileUpload1.FileName);
string filepath = getFolder() + "\\" + FileUpload1.FileName;
FileUpload1.SaveAs(filepath);
ExcelReader er = null;
List<int> cannotimport;
try
{
er = new ExcelReader(filepath);
using (var db = new huadushuiEntities())
{
cannotimport= er.getShouFei(db);
/* tb_anzuangwei meter = db.tb_anzuangwei.FirstOrDefault(m => m.bm == dym);
if (meter == null)
{
Page.AlertThis("永久编号为"+dym+"的水表不存在请确认是否新水表!");
return;
}
er.qiyeid = meter.qiyeid.Value;
//if (er.qiyeid>0)
rowaffect = er.getData(db);
/* list.ForEach(m =>
{
db.tb_jfxx.AddObject(m);
db.SaveChanges();
后面还有 42 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
