248 lines
9.4 KiB
C#
248 lines
9.4 KiB
C#
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|||
|
{
|
|||
|
using System;
|
|||
|
using System.IO;
|
|||
|
using System.Web.UI;
|
|||
|
using BLL;
|
|||
|
|
|||
|
public partial class ProcedureImageEdit : PageBase
|
|||
|
{
|
|||
|
#region 定义项
|
|||
|
/// <summary>
|
|||
|
/// 工艺文件图片id
|
|||
|
/// </summary>
|
|||
|
public string ImageId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ImageId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ImageId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 附件路径
|
|||
|
/// </summary>
|
|||
|
public string FullAttachUrl
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["FullAttachUrl"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["FullAttachUrl"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
this.ImageId = Request.Params["ImageId"];
|
|||
|
///焊接方法
|
|||
|
this.drpWeldingMethod.DataTextField = "WME_Name";
|
|||
|
this.drpWeldingMethod.DataValueField = "WME_ID";
|
|||
|
this.drpWeldingMethod.DataSource = BLL.HJGL_WeldingMethodService.GetWeldMethodNameList();
|
|||
|
this.drpWeldingMethod.DataBind();
|
|||
|
Funs.FineUIPleaseSelect(this.drpWeldingMethod);
|
|||
|
///焊缝类型
|
|||
|
this.drpJOTYID.DataTextField = "JOTY_Name";
|
|||
|
this.drpJOTYID.DataValueField = "JOTY_ID";
|
|||
|
this.drpJOTYID.DataSource = BLL.HJGL_WeldService.GetJointTypeNameList("2");
|
|||
|
this.drpJOTYID.DataBind();
|
|||
|
Funs.FineUIPleaseSelect(this.drpJOTYID);
|
|||
|
///坡口类型
|
|||
|
this.drpJSTID.DataTextField = "JST_Name";
|
|||
|
this.drpJSTID.DataValueField = "JST_ID";
|
|||
|
this.drpJSTID.DataSource = BLL.HJGL_GrooveService.GetSlopeTypeNameList();
|
|||
|
this.drpJSTID.DataBind();
|
|||
|
Funs.FineUIPleaseSelect(this.drpJSTID);
|
|||
|
|
|||
|
this.PersonLoad();
|
|||
|
if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ProcedureImageListMenuId, Const.BtnSave))
|
|||
|
{
|
|||
|
this.btnUpFile.Hidden = true;
|
|||
|
this.btnDelete.Hidden = true;
|
|||
|
this.btnSave.Hidden = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 初始化页面信息
|
|||
|
/// <summary>
|
|||
|
/// 初始化页面信息
|
|||
|
/// </summary>
|
|||
|
protected void PersonLoad()
|
|||
|
{
|
|||
|
var procedureImage = BLL.HJGL_ProcedureImageService.GetImageById(this.ImageId);
|
|||
|
if (procedureImage != null)
|
|||
|
{
|
|||
|
this.txtImageContent.Text = procedureImage.ImageContent;
|
|||
|
if (!string.IsNullOrEmpty(procedureImage.WME_ID))
|
|||
|
{
|
|||
|
this.drpWeldingMethod.SelectedValue = procedureImage.WME_ID;
|
|||
|
}
|
|||
|
if (procedureImage.Thickness != null)
|
|||
|
{
|
|||
|
this.txtThikness.Text = Convert.ToString(procedureImage.Thickness);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(procedureImage.JOTY_ID))
|
|||
|
{
|
|||
|
this.drpJOTYID.SelectedValue = procedureImage.JOTY_ID;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(procedureImage.JST_ID))
|
|||
|
{
|
|||
|
this.drpJSTID.SelectedValue = procedureImage.JST_ID;
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(procedureImage.AttachUrl))
|
|||
|
{
|
|||
|
this.FullAttachUrl = procedureImage.AttachUrl;
|
|||
|
this.lbAttachUrl.Text = procedureImage.AttachUrl.Substring(procedureImage.AttachUrl.IndexOf("~") + 1);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 附件上传
|
|||
|
/// <summary>
|
|||
|
/// 附件上传
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnUpFile_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (fuAttachUrl.HasFile)
|
|||
|
{
|
|||
|
this.lbAttachUrl.Text = fuAttachUrl.ShortFileName;
|
|||
|
if (ValidateFileTypes(this.lbAttachUrl.Text))
|
|||
|
{
|
|||
|
ShowNotify("无效的文件类型!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
this.FullAttachUrl = BLL.UploadFileService.UploadAttachment(BLL.Funs.RootPath, this.fuAttachUrl, this.FullAttachUrl, BLL.Const.HJGL_ImageUrl);
|
|||
|
if (string.IsNullOrEmpty(this.FullAttachUrl))
|
|||
|
{
|
|||
|
ShowNotify("文件名已经存在!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("文件上传成功!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("上传文件不存在!", MessageBoxIcon.Warning);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查看附件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSee_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string filePath = BLL.Funs.RootPath + this.FullAttachUrl;
|
|||
|
string fileName = Path.GetFileName(filePath);
|
|||
|
FileInfo info = new FileInfo(filePath);
|
|||
|
if (info.Exists)
|
|||
|
{
|
|||
|
long fileSize = info.Length;
|
|||
|
Response.Clear();
|
|||
|
Response.ContentType = "application/x-zip-compressed";
|
|||
|
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|||
|
Response.AddHeader("Content-Length", fileSize.ToString());
|
|||
|
Response.TransmitFile(filePath, 0, fileSize);
|
|||
|
Response.Flush();
|
|||
|
Response.Close();
|
|||
|
this.SimpleForm1.Reset();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("附件不存在!", MessageBoxIcon.Warning);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 删除附件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnDelete_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.fuAttachUrl.Reset();
|
|||
|
this.lbAttachUrl.Text = string.Empty;
|
|||
|
this.FullAttachUrl = string.Empty;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 提交按钮
|
|||
|
/// <summary>
|
|||
|
/// 提交按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ProcedureImageListMenuId, Const.BtnSave))
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(this.txtImageContent.Text.Trim()))
|
|||
|
{
|
|||
|
Alert.ShowInTop("图片摘要不能为空!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Model.HJGL_PW_ProcedureImageManage procedureImage = new Model.HJGL_PW_ProcedureImageManage();
|
|||
|
procedureImage.ImageContent = this.txtImageContent.Text.Trim();
|
|||
|
if (this.drpWeldingMethod.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
procedureImage.WME_ID = this.drpWeldingMethod.SelectedValue;
|
|||
|
}
|
|||
|
procedureImage.Thickness = Funs.GetNewDecimal(this.txtThikness.Text.Trim());
|
|||
|
if (this.drpJOTYID.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
procedureImage.JOTY_ID = this.drpJOTYID.SelectedValue;
|
|||
|
}
|
|||
|
if (this.drpJSTID.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
procedureImage.JST_ID = this.drpJSTID.SelectedValue;
|
|||
|
}
|
|||
|
procedureImage.AttachUrl = this.FullAttachUrl;
|
|||
|
if (string.IsNullOrEmpty(this.ImageId))
|
|||
|
{
|
|||
|
procedureImage.ImageId = SQLHelper.GetNewID(typeof(Model.HJGL_PW_ProcedureImageManage));
|
|||
|
BLL.HJGL_ProcedureImageService.AddProcedureImage(procedureImage);
|
|||
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加图片信息");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
procedureImage.ImageId = this.ImageId;
|
|||
|
BLL.HJGL_ProcedureImageService.UpdateProcedureImage(procedureImage);
|
|||
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改图片信息!");
|
|||
|
}
|
|||
|
|
|||
|
Alert.ShowInTop("提交成功!", MessageBoxIcon.Success);
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|