307 lines
11 KiB
C#
307 lines
11 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.CQMS.Check
|
|
{
|
|
public partial class MaterialAcceptanceEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string MaterialAcceptanceId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["MaterialAcceptanceId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["MaterialAcceptanceId"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 办理类型
|
|
/// </summary>
|
|
public string State
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["State"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["State"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
MaterialAcceptanceId = Request.Params["MaterialAcceptanceId"];
|
|
BLL.Base_CompanytemplateService.InitBase_CompanyTemplateDownList(drpCompanyTemplate, true);
|
|
IsHiddendrpCompanyTemplate();
|
|
if (!string.IsNullOrEmpty(MaterialAcceptanceId))
|
|
{
|
|
var MainPlan = BLL.CheckMaterialacceptanceService.GetCheck_MaterialAcceptanceById(MaterialAcceptanceId);
|
|
hdId.Text = this.MaterialAcceptanceId;
|
|
txtPlanCode.Text = MainPlan.PlanCode;
|
|
txtFileName.Text = MainPlan.FileName;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
string prefix = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId) + "-ZLYS-";
|
|
txtPlanCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "Check_MaterialAcceptance", "PlanCode", this.CurrUser.LoginProjectId, prefix);
|
|
txtFileName.Text = "材料验收";
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 时间转换
|
|
/// </summary>
|
|
/// <param name="date"></param>
|
|
/// <returns></returns>
|
|
public string ConvertDate(object date)
|
|
{
|
|
if (date != null)
|
|
{
|
|
return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date));
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
protected void imgBtnFile_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(hdId.Text))
|
|
{
|
|
hdId.Text = SQLHelper.GetNewID();
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/Plan&menuId={1}", hdId.Text, BLL.Const.CheckMaterialacceptanceMenuId)));
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
SaveMainPlan("save");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
public void SaveMainPlan(string saveType)
|
|
{
|
|
Model.Check_MaterialAcceptance MaterialAcceptance = new Model.Check_MaterialAcceptance();
|
|
MaterialAcceptance.ProjectId = this.CurrUser.LoginProjectId;
|
|
MaterialAcceptance.PlanCode = this.txtPlanCode.Text.Trim();
|
|
MaterialAcceptance.FileName = this.txtFileName.Text.Trim();
|
|
MaterialAcceptance.FilePath = "FileUpload/CQMS_Check_MaterialAcceptance/" + txtPlanCode.Text + ".doc";
|
|
|
|
if (!string.IsNullOrEmpty(MaterialAcceptanceId))
|
|
{
|
|
MaterialAcceptance.MaterialAcceptanceId = MaterialAcceptanceId;
|
|
CheckMaterialacceptanceService.UpdateCheck_MaterialAcceptance(MaterialAcceptance);
|
|
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrEmpty(hdId.Text))
|
|
{
|
|
MaterialAcceptance.MaterialAcceptanceId = SQLHelper.GetNewID();
|
|
hdId.Text = MaterialAcceptance.MaterialAcceptanceId;
|
|
MaterialAcceptanceId = MaterialAcceptance.MaterialAcceptanceId;
|
|
}
|
|
else
|
|
{
|
|
MaterialAcceptance.MaterialAcceptanceId = hdId.Text;
|
|
MaterialAcceptanceId = hdId.Text;
|
|
}
|
|
MaterialAcceptance.CompileMan = this.CurrUser.PersonId;
|
|
MaterialAcceptance.CompileDate = DateTime.Now;
|
|
CheckMaterialacceptanceService.AddCheck_MaterialAcceptance(MaterialAcceptance);
|
|
|
|
}
|
|
LogService.AddSys_Log(CurrUser, MaterialAcceptance.PlanCode, MaterialAcceptance.MaterialAcceptanceId, Const.CheckMaterialacceptanceMenuId, "修改总包施工质量计划");
|
|
if (saveType == "submit")
|
|
{
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 表格数据验证
|
|
/// </summary>
|
|
private bool validate()
|
|
{
|
|
bool res = false;
|
|
string err = string.Empty;
|
|
var att = BLL.AttachFileService.GetAttachFileByToKeyId(this.hdId.Text);
|
|
if (att == null)
|
|
{
|
|
err += "请上传文件!";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(err))
|
|
{
|
|
Alert.ShowInTop(err, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
return res;
|
|
}
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
|
|
SaveMainPlan("submit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string GetStringByArray(string[] array)
|
|
{
|
|
string str = string.Empty;
|
|
foreach (var item in array)
|
|
{
|
|
if (item != BLL.Const._Null)
|
|
{
|
|
str += item + ",";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(str))
|
|
{
|
|
str = str.Substring(0, str.LastIndexOf(","));
|
|
}
|
|
return str;
|
|
}
|
|
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
|
|
{
|
|
string rootPath = Funs.RootPath;
|
|
var model = BLL.CheckMaterialacceptanceService.GetCheck_MaterialAcceptanceById(MaterialAcceptanceId);
|
|
string filepath = model.FilePath;
|
|
string path = rootPath + filepath;
|
|
DirectoryInfo pathInfo = new DirectoryInfo(path);
|
|
string newPath = pathInfo.Parent.FullName;
|
|
if (!Directory.Exists(newPath))
|
|
{
|
|
Directory.CreateDirectory(newPath);
|
|
}
|
|
if (drpCompanyTemplate.SelectedValue != Const._Null)
|
|
{
|
|
var template = BLL.Base_CompanytemplateService.GetBase_CompanyTemplateById(drpCompanyTemplate.SelectedValue);
|
|
File.Copy(rootPath + template.FilePath, path);
|
|
|
|
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/IndexOffice.aspx?cmd={0}|CQMS_Check_MaterialAcceptance", MaterialAcceptanceId, "查看 -")));
|
|
PageContext.RegisterStartupScript(WindowAtt.GetHideReference());
|
|
}
|
|
private void GetCompanyTemplate()
|
|
{
|
|
string rootPath = Funs.RootPath;
|
|
var model = BLL.CheckMaterialacceptanceService.GetCheck_MaterialAcceptanceById(MaterialAcceptanceId);
|
|
string filepath = model.FilePath;
|
|
string path = rootPath + filepath;
|
|
DirectoryInfo pathInfo = new DirectoryInfo(path);
|
|
string newPath = pathInfo.Parent.FullName;
|
|
if (!Directory.Exists(newPath))
|
|
{
|
|
Directory.CreateDirectory(newPath);
|
|
}
|
|
if (drpCompanyTemplate.SelectedValue != Const._Null)
|
|
{
|
|
var template = BLL.Base_CompanytemplateService.GetBase_CompanyTemplateById(drpCompanyTemplate.SelectedValue);
|
|
File.Copy(rootPath + template.FilePath, path);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请选择模板", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/IndexOffice.aspx?cmd={0}|CQMS_Check_MaterialAcceptance", MaterialAcceptanceId, "查看 -")));
|
|
PageContext.RegisterStartupScript(WindowAtt.GetHideReference());
|
|
|
|
}
|
|
/// <summary>
|
|
/// 是否隐藏选择模板
|
|
/// </summary>
|
|
protected void IsHiddendrpCompanyTemplate()
|
|
{
|
|
if (!string.IsNullOrEmpty(MaterialAcceptanceId))
|
|
{
|
|
Model.Check_MaterialAcceptance Materialacceptance = BLL.CheckMaterialacceptanceService.GetCheck_MaterialAcceptanceById(MaterialAcceptanceId);
|
|
if (!File.Exists(Funs.RootPath + Materialacceptance.FilePath))
|
|
{
|
|
|
|
drpCompanyTemplate.Hidden = false;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
drpCompanyTemplate.Hidden = false;
|
|
}
|
|
|
|
|
|
}
|
|
protected void btnEditWord_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(MaterialAcceptanceId))
|
|
{
|
|
Model.Check_MaterialAcceptance Materialacceptance = BLL.CheckMaterialacceptanceService.GetCheck_MaterialAcceptanceById(MaterialAcceptanceId);
|
|
if (!File.Exists(Funs.RootPath + Materialacceptance.FilePath))
|
|
{
|
|
GetCompanyTemplate();
|
|
//PageContext.RegisterStartupScript(Confirm.GetShowReference("是否使用公司模板?",
|
|
// String.Empty,
|
|
// MessageBoxIcon.Question,
|
|
// PageManager1.GetCustomEventReference("Yes"), // 第一个参数 false 用来指定当前不是AJAX请求
|
|
// PageManager1.GetCustomEventReference("No")));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/IndexOffice.aspx?cmd={0}|CQMS_Check_MaterialAcceptance", MaterialAcceptanceId, "查看 -")));
|
|
PageContext.RegisterStartupScript(WindowAtt.GetHideReference());
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SaveMainPlan("save");
|
|
GetCompanyTemplate();
|
|
}
|
|
//PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/IndexOffice.aspx?cmd={0}", filepath, "查看 -")));
|
|
}
|
|
}
|
|
} |