615 lines
26 KiB
C#
615 lines
26 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.CQMS.Comprehensive
|
|
{
|
|
public partial class InspectionMachineDataInNew : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 错误集合
|
|
/// </summary>
|
|
public static string errorInfos = string.Empty;
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
if (percent == null)
|
|
{
|
|
percent = new Dictionary<string, int>();
|
|
}
|
|
this.id.Text = this.CurrUser.UserId;
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
else if (GetRequestEventArgument() == "reloadGrid")
|
|
{
|
|
BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT TempId,ProjectId,UserId,Time,RowNo,ToopValue,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,Value10"
|
|
+ @" ,Value11,Value12,Value13,Value14,Value15,Value16,Value17,Value18,Value19,Value20"
|
|
+ @",ToopValue,Type"
|
|
+ @" FROM Sys_CQMS_DataInTemp "
|
|
+ @" WHERE ProjectId=@ProjectId AND UserId=@UserId AND Type=@Type";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId));
|
|
listStr.Add(new SqlParameter("@Type", "InspectionMachine"));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
|
|
var dataInTempAll = from x in Funs.DB.Sys_CQMS_DataInTemp
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.UserId == this.CurrUser.UserId && x.Type == "InspectionMachine"
|
|
select x;
|
|
for (int i = 0; i < Grid1.Rows.Count; i++)
|
|
{
|
|
var dataInTemp = dataInTempAll.FirstOrDefault(x => x.TempId == Grid1.Rows[i].DataKeys[0].ToString());
|
|
if (dataInTemp != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(dataInTemp.ToopValue))
|
|
{
|
|
Grid1.Rows[i].RowCssClass = "red";
|
|
}
|
|
}
|
|
}
|
|
var errData = from x in dataInTempAll where x.ToopValue != null select x;
|
|
this.lbDataCout.Text = errData.Count().ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region 双击事件
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectionMachineDataInNewEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
|
|
}
|
|
#endregion
|
|
|
|
#region 导入信息 维护
|
|
/// <summary>
|
|
/// 导入信息编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InspectionMachineDataInNewEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
BLL.Sys_CQMS_DataInTempService.DeleteDataInTempByDataInTempID(rowID);
|
|
}
|
|
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 文件上传
|
|
/// <summary>
|
|
/// 文件上传
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void imgbtnImport_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.FileExcel.HasFile == false)
|
|
{
|
|
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string IsXls = Path.GetExtension(this.FileExcel.FileName).ToString().Trim().ToLower();
|
|
if (IsXls != ".xls" && IsXls != ".xlsx")
|
|
{
|
|
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string rootPath = Server.MapPath("~/");
|
|
string initFullPath = rootPath + Const.ExcelUrl;
|
|
if (!Directory.Exists(initFullPath))
|
|
{
|
|
Directory.CreateDirectory(initFullPath);
|
|
}
|
|
//指定上传文件名称
|
|
this.hdfileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
|
//上传文件路径
|
|
string filePath = initFullPath + this.hdfileName.Text;
|
|
//文件上传服务器
|
|
this.FileExcel.PostedFile.SaveAs(filePath);
|
|
//文件上传服务器后的名称
|
|
string fileName = rootPath + Const.ExcelUrl + this.hdfileName.Text;
|
|
//读取Excel
|
|
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
|
//验证Excel读取是否有误
|
|
if (!string.IsNullOrEmpty(errorInfos))
|
|
{
|
|
ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
if (ds.Tables.Count > 0)
|
|
{
|
|
for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
|
|
{
|
|
Sys_CQMS_DataInTemp newDataInTemp = new Sys_CQMS_DataInTemp();
|
|
newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.Sys_CQMS_DataInTemp));
|
|
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
|
|
newDataInTemp.UserId = this.CurrUser.UserId;
|
|
newDataInTemp.Time = System.DateTime.Now;
|
|
newDataInTemp.Type = "InspectionMachine";
|
|
newDataInTemp.RowNo = i + 2;
|
|
newDataInTemp.Value1 = ds.Tables[0].Rows[i][0].ToString();
|
|
newDataInTemp.Value2 = ds.Tables[0].Rows[i][1].ToString();
|
|
newDataInTemp.Value3 = ds.Tables[0].Rows[i][2].ToString();
|
|
newDataInTemp.Value4 = ds.Tables[0].Rows[i][3].ToString();
|
|
newDataInTemp.Value5 = ds.Tables[0].Rows[i][4].ToString();
|
|
newDataInTemp.Value6 = ds.Tables[0].Rows[i][5].ToString();
|
|
newDataInTemp.Value7 = ds.Tables[0].Rows[i][6].ToString();
|
|
newDataInTemp.Value8 = ds.Tables[0].Rows[i][7].ToString();
|
|
newDataInTemp.Value9 = ds.Tables[0].Rows[i][8].ToString();
|
|
newDataInTemp.Value10 = ds.Tables[0].Rows[i][9].ToString();
|
|
newDataInTemp.Value11 = ds.Tables[0].Rows[i][10].ToString();
|
|
newDataInTemp.Value12 = ds.Tables[0].Rows[i][11].ToString();
|
|
newDataInTemp.Value13 = ds.Tables[0].Rows[i][12].ToString();
|
|
newDataInTemp.Value14 = ds.Tables[0].Rows[i][13].ToString();
|
|
newDataInTemp.Value15 = ds.Tables[0].Rows[i][14].ToString();
|
|
|
|
BLL.Sys_CQMS_DataInTempService.AddDataInTemp(newDataInTemp);
|
|
}
|
|
this.BindGrid();
|
|
ShowNotify("数据已导入临时表!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("导入数据为空!", MessageBoxIcon.Success);
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert.ShowInTop("'" + ex.Message + "'", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("机具报验" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
#endregion
|
|
|
|
#region 保存审核事件
|
|
/// <summary>
|
|
/// 保存审核事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
Thread t = new Thread(new ThreadStart(() => { btnSaveMethod(this.CurrUser.LoginProjectId, this.CurrUser.UserId, "InspectionMachine"); }));
|
|
t.Start();
|
|
if (percent.ContainsKey(this.CurrUser.UserId))
|
|
{
|
|
percent[CurrUser.UserId] = 0;
|
|
}
|
|
else
|
|
{
|
|
percent.Add(CurrUser.UserId, 0);
|
|
|
|
}
|
|
PageContext.RegisterStartupScript("printX()");
|
|
}
|
|
protected void btnRefresh_Click(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
protected void btnSaveMethod(string LoginProjectId, string UserId, string IsPDMS)
|
|
{
|
|
var oldViewInfos = from x in Funs.DB.Comprehensive_InspectionMachine
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
select x;
|
|
|
|
var units = from x in Funs.DB.Base_Unit
|
|
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
|
|
where y.ProjectId == this.CurrUser.LoginProjectId
|
|
select x;
|
|
|
|
var cns = from x in Funs.DB.Base_CNProfessional select x;
|
|
|
|
var dataInTemp = from x in Funs.DB.Sys_CQMS_DataInTemp
|
|
where x.ProjectId == LoginProjectId && x.UserId == UserId && x.Type == "InspectionMachine"
|
|
select x;
|
|
int okCount = 0;
|
|
int i = 0;
|
|
int ir = dataInTemp.Count();
|
|
string erreMessage = "";
|
|
foreach (var tempData in dataInTemp)
|
|
{
|
|
if (tempData != null)
|
|
{
|
|
i++;
|
|
percent[UserId] = (int)(100 * i / ir);
|
|
string errInfo = string.Empty;
|
|
|
|
Model.Comprehensive_InspectionMachine Ins = new Model.Comprehensive_InspectionMachine();
|
|
if (!string.IsNullOrEmpty(tempData.Value1.Trim()))
|
|
{
|
|
var unit = units.FirstOrDefault(x => x.UnitName == tempData.Value1.Trim());
|
|
if (unit == null)
|
|
{
|
|
errInfo += "报验单位[" + tempData.Value1.Trim() + "]不存在;";
|
|
}
|
|
else
|
|
{
|
|
Ins.UnitId = unit.UnitId;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errInfo += "报验单位为必填项;";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value2.Trim()))
|
|
{
|
|
Ins.InspectionMachineCode = tempData.Value2.Trim();
|
|
}
|
|
else
|
|
{
|
|
errInfo += "报验编号为必填项;";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value3.Trim()))
|
|
{
|
|
Ins.InspectionMachineName = tempData.Value3.Trim();
|
|
}
|
|
else
|
|
{
|
|
errInfo += "机具名称为必填项;";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value4.Trim()))
|
|
{
|
|
var cn = cns.Where(x => x.ProfessionalName == tempData.Value4.Trim()).FirstOrDefault();
|
|
if (cn == null)
|
|
{
|
|
errInfo += "专业名称[" + tempData.Value4.Trim() + "]不存在;";
|
|
}
|
|
else
|
|
{
|
|
Ins.CNProfessionalId = cn.CNProfessionalId;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value5.Trim()))
|
|
{
|
|
if (tempData.Value5 != "施工" && tempData.Value5.Trim() != "计量")
|
|
{
|
|
errInfo += "类型[" + tempData.Value5.Trim() + "]错误;";
|
|
}
|
|
else
|
|
{
|
|
Ins.InspectionType = tempData.Value5.Trim();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Ins.InspectionType = "施工";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value6.Trim()))
|
|
{
|
|
Ins.SpecificationModel = tempData.Value6.Trim();
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value7.Trim()))
|
|
{
|
|
try
|
|
{
|
|
Ins.NextTestDate = Funs.GetNewDateTime(tempData.Value7.Trim());
|
|
if (Ins.NextTestDate == null)
|
|
{
|
|
errInfo += "下次检验日期 [" + tempData.Value7.Trim() + "]错误;";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errInfo += "下次检验日期 [" + tempData.Value7.Trim() + "]错误;";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value8.Trim()))
|
|
{
|
|
Ins.TestCycle = tempData.Value8.Trim();
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value9.Trim()))
|
|
{
|
|
if (tempData.Value9.Trim() != "是" && tempData.Value9.Trim() != "否")
|
|
{
|
|
errInfo += "是否在校验期内[" + tempData.Value9.Trim() + "]错误;";
|
|
}
|
|
else
|
|
{
|
|
Ins.IsVerification = tempData.Value9.Trim() == "是" ? true : false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errInfo += "是否在校验期内为必填项;";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value10.Trim()))
|
|
{
|
|
try
|
|
{
|
|
Ins.InspectionDate = Funs.GetNewDateTime(tempData.Value10.Trim());
|
|
if (Ins.InspectionDate == null)
|
|
{
|
|
errInfo += "报验日期[" + tempData.Value10.Trim() + "]错误;";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errInfo += "报验日期[" + tempData.Value10.Trim() + "]错误;";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value11.Trim()))
|
|
{
|
|
if (tempData.Value11.Trim() != "是" && tempData.Value11.Trim() != "否")
|
|
{
|
|
errInfo += "是否在场[" + tempData.Value11.Trim() + "]错误;";
|
|
}
|
|
else
|
|
{
|
|
Ins.IsOnSite = tempData.Value11.Trim() == "是" ? true : false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errInfo += "是否在场为必填项;";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value12.Trim()))
|
|
{
|
|
try
|
|
{
|
|
Ins.UnitsCount = Funs.GetNewInt(tempData.Value12.Trim());
|
|
if (Ins.UnitsCount==null)
|
|
{
|
|
errInfo += "台数[" + tempData.Value12.Trim() + "]错误;";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errInfo += "台数[" + tempData.Value12.Trim() + "]错误;";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value13.Trim()))
|
|
{
|
|
if (tempData.Value13.Trim() != "是" && tempData.Value13.Trim() != "否")
|
|
{
|
|
errInfo += "校验合格[" + tempData.Value13.Trim() + "]错误;";
|
|
}
|
|
else
|
|
{
|
|
Ins.IsCheckOK = tempData.Value13.Trim() == "是" ? true : false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errInfo += "校验合格为必填项;";
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value14.Trim()))
|
|
{
|
|
try
|
|
{
|
|
Ins.LeaveDate = Funs.GetNewDateTime(tempData.Value14.Trim());
|
|
if (Ins.LeaveDate==null)
|
|
{
|
|
errInfo += "离场时间[" + tempData.Value14.Trim() + "]错误;";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errInfo += "离场时间[" + tempData.Value14.Trim() + "]错误;";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(tempData.Value15.Trim()))
|
|
{
|
|
try
|
|
{
|
|
Ins.RemarkCode = Convert.ToInt32(tempData.Value15.Trim());
|
|
if (Ins.RemarkCode == null)
|
|
{
|
|
errInfo += "标志编号[" + tempData.Value15.Trim() + "]格式错误;";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errInfo += "标志编号[" + tempData.Value15.Trim() + "]格式错误;";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errInfo += "标志编号为必填项;";
|
|
}
|
|
Ins.CompileMan = this.CurrUser.UserId;
|
|
Ins.CompileDate = DateTime.Now.Date;
|
|
if (string.IsNullOrEmpty(errInfo)) ////所有信息正确的话 插入数据
|
|
{
|
|
Ins.ProjectId = LoginProjectId;
|
|
var isExitISOValue = oldViewInfos.FirstOrDefault(x => x.UnitId == Ins.UnitId
|
|
&& x.RemarkCode == Funs.GetNewIntOrZero(tempData.Value15));
|
|
if (isExitISOValue != null) ///已存在
|
|
{
|
|
Ins.InspectionMachineId = isExitISOValue.InspectionMachineId;
|
|
BLL.InspectionMachineService.UpdateInspectionMachine(Ins);
|
|
}
|
|
else
|
|
{
|
|
Ins.Status = BLL.Const.Comprehensive_Compile;
|
|
Ins.InspectionMachineId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionMachine));
|
|
BLL.InspectionMachineService.AddInspectionMachine(Ins);
|
|
}
|
|
BLL.Sys_CQMS_DataInTempService.DeleteDataInTempByDataInTempID(tempData.TempId);
|
|
okCount++;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(errInfo))
|
|
{
|
|
tempData.ToopValue = errInfo;
|
|
BLL.Sys_CQMS_DataInTempService.UpdateDataInTemp(tempData);
|
|
erreMessage += errInfo + ";";
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除所有数据事件
|
|
/// <summary>
|
|
/// 删除所有数据事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAllDelete_Click(object sender, EventArgs e)
|
|
{
|
|
//先删除临时表中 该人员以前导入的数据
|
|
BLL.Sys_CQMS_DataInTempService.DeleteDataInTempByProjectIdUserId(this.CurrUser.LoginProjectId, this.CurrUser.UserId, "InspectionMachine");
|
|
this.BindGrid();
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
this.lbDataCout.Text = string.Empty;
|
|
}
|
|
#endregion
|
|
|
|
#region 模版导入说明 下载
|
|
/// <summary>
|
|
/// 下载模版
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void imgbtnUpload_Click(object sender, EventArgs e)
|
|
{
|
|
string rootPath = Server.MapPath("~/");
|
|
string uploadfilepath = rootPath + Const.InspectionMachineDataInUrl;
|
|
string filePath = Const.InspectionMachineDataInUrl;
|
|
string fileName = Path.GetFileName(filePath);
|
|
FileInfo info = new FileInfo(uploadfilepath);
|
|
long fileSize = info.Length;
|
|
Response.ClearContent();
|
|
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
Response.ContentType = "excel/plain";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.AddHeader("Content-Length", fileSize.ToString().Trim());
|
|
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
|
Response.End();
|
|
}
|
|
#endregion
|
|
|
|
public static Dictionary<string, int> percent { get; set; }
|
|
public static Dictionary<string, string> url { get; set; }
|
|
|
|
[System.Web.Services.WebMethod]
|
|
public static int getPercent(string id)
|
|
{
|
|
return percent[id];
|
|
}
|
|
}
|
|
} |