11
This commit is contained in:
@@ -187,7 +187,7 @@ namespace FineUIPro.Web.WelderManage
|
||||
#region 右键编辑
|
||||
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.Welder_QualifiedProjectMenuId, BLL.Const.BtnModify))
|
||||
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WelderTestInfoMenuId, BLL.Const.BtnModify))
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
@@ -210,7 +210,7 @@ namespace FineUIPro.Web.WelderManage
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.Welder_QualifiedProjectMenuId, Const.BtnDelete))
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WelderTestInfoMenuId, Const.BtnDelete))
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
@@ -319,100 +319,107 @@ namespace FineUIPro.Web.WelderManage
|
||||
|
||||
protected void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
string message = string.Empty;
|
||||
errorInfos = string.Empty;
|
||||
try
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WelderTestInfoMenuId, Const.BtnIn))
|
||||
{
|
||||
if (this.fileUpload.HasFile == false)
|
||||
string message = string.Empty;
|
||||
errorInfos = string.Empty;
|
||||
try
|
||||
{
|
||||
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string IsXls = Path.GetExtension(this.fileUpload.FileName).ToString().Trim().ToLower();
|
||||
if (IsXls != ".xls" && IsXls != ".xlsx")
|
||||
{
|
||||
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initFullPath = rootPath + initPath;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
{
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
//指定上传文件名称
|
||||
this.hidFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||||
//上传文件路径
|
||||
string filePath = initFullPath + this.hidFileName.Text;
|
||||
//文件上传服务器
|
||||
this.fileUpload.PostedFile.SaveAs(filePath);
|
||||
//文件上传服务器后的名称
|
||||
string fileName = rootPath + initPath + this.hidFileName.Text;
|
||||
//读取Excel
|
||||
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
||||
//验证Excel读取是否有误
|
||||
if (!string.IsNullOrEmpty(errorInfos))
|
||||
{
|
||||
ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
DataTable dt = ds.Tables[0];
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
List<Model.Welder_TestInfo> listData = new List<Model.Welder_TestInfo>();
|
||||
var validate = ValidateImportFileds(dt);
|
||||
if(validate!=null && validate.Count > 0)
|
||||
if (this.fileUpload.HasFile == false)
|
||||
{
|
||||
Cache["errLog"] = validate;
|
||||
//提示错误信息
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference("WelderTestInfoImportError.aspx"));
|
||||
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string IsXls = Path.GetExtension(this.fileUpload.FileName).ToString().Trim().ToLower();
|
||||
if (IsXls != ".xls" && IsXls != ".xlsx")
|
||||
{
|
||||
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initFullPath = rootPath + initPath;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
{
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
//指定上传文件名称
|
||||
this.hidFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||||
//上传文件路径
|
||||
string filePath = initFullPath + this.hidFileName.Text;
|
||||
//文件上传服务器
|
||||
this.fileUpload.PostedFile.SaveAs(filePath);
|
||||
//文件上传服务器后的名称
|
||||
string fileName = rootPath + initPath + this.hidFileName.Text;
|
||||
//读取Excel
|
||||
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
||||
//验证Excel读取是否有误
|
||||
if (!string.IsNullOrEmpty(errorInfos))
|
||||
{
|
||||
ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
DataTable dt = ds.Tables[0];
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
List<Model.Welder_TestInfo> listData = new List<Model.Welder_TestInfo>();
|
||||
var validate = ValidateImportFileds(dt);
|
||||
if (validate != null && validate.Count > 0)
|
||||
{
|
||||
Cache["errLog"] = validate;
|
||||
//提示错误信息
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference("WelderTestInfoImportError.aspx"));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
Model.Welder_TestInfo model = new Model.Welder_TestInfo();
|
||||
string welderCode = dr[0].ToString();
|
||||
string weldMethod = dr[1].ToString();
|
||||
string weldMeatrail = dr[2].ToString();
|
||||
string isPass = dr[3].ToString();
|
||||
string testDate = dr[4].ToString();
|
||||
string remark = dr[5].ToString();
|
||||
|
||||
var welderId = Funs.DB.Welder_Welder.FirstOrDefault(t => t.WelderCode == welderCode)?.WelderId;
|
||||
var methodId = Funs.DB.Base_WeldingMethod.FirstOrDefault(t => t.WeldingMethodCode == weldMethod)?.WeldingMethodId;
|
||||
var materId = Funs.DB.Base_Material.FirstOrDefault(t => t.MaterialCode == weldMeatrail)?.MaterialId;
|
||||
model.Id = SQLHelper.GetNewID(typeof(Model.Welder_TestInfo));
|
||||
model.WeldMethodId = methodId;
|
||||
model.MaterialId = materId;
|
||||
model.IsPass = isPass == "是" ? true : false;
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.WelderId = welderId;
|
||||
model.CreatedDate = DateTime.Parse(testDate);
|
||||
model.Remark = remark;
|
||||
listData.Add(model);
|
||||
}
|
||||
}
|
||||
|
||||
if (listData.Count > 0)
|
||||
{
|
||||
Funs.DB.Welder_TestInfo.InsertAllOnSubmit(listData);
|
||||
Funs.DB.SubmitChanges();
|
||||
ShowNotify("导入成功", MessageBoxIcon.Success);
|
||||
this.BindGrid();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
Model.Welder_TestInfo model = new Model.Welder_TestInfo();
|
||||
string welderCode = dr[0].ToString();
|
||||
string weldMethod = dr[1].ToString();
|
||||
string weldMeatrail = dr[2].ToString();
|
||||
string isPass = dr[3].ToString();
|
||||
string testDate = dr[4].ToString();
|
||||
string remark = dr[5].ToString();
|
||||
|
||||
var welderId = Funs.DB.Welder_Welder.FirstOrDefault(t => t.WelderCode == welderCode)?.WelderId;
|
||||
var methodId = Funs.DB.Base_WeldingMethod.FirstOrDefault(t => t.WeldingMethodCode == weldMethod)?.WeldingMethodId;
|
||||
var materId = Funs.DB.Base_Material.FirstOrDefault(t => t.MaterialCode == weldMeatrail)?.MaterialId;
|
||||
model.Id = SQLHelper.GetNewID(typeof(Model.Welder_TestInfo));
|
||||
model.WeldMethodId= methodId;
|
||||
model.MaterialId= materId;
|
||||
model.IsPass = isPass == "是" ? true : false;
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.WelderId= welderId;
|
||||
model.CreatedDate = DateTime.Parse(testDate);
|
||||
model.Remark = remark;
|
||||
listData.Add(model);
|
||||
}
|
||||
ShowAlert("没有数据!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if(listData.Count > 0)
|
||||
{
|
||||
Funs.DB.Welder_TestInfo.InsertAllOnSubmit(listData);
|
||||
Funs.DB.SubmitChanges();
|
||||
ShowNotify("导入成功", MessageBoxIcon.Success);
|
||||
this.BindGrid();
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowAlert("没有数据!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
ShowAlert("'" + ex.Message + "'", MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
ShowAlert("'" + ex.Message + "'", MessageBoxIcon.Warning);
|
||||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,7 +492,7 @@ namespace FineUIPro.Web.WelderManage
|
||||
/// <param name="e"></param>
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.Welder_QualifiedProjectMenuId, Const.BtnAdd))
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WelderTestInfoMenuId, Const.BtnAdd))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user