HJGL_DS/HJGL_DS/FineUIPro.Web/HJGL/MaterialManage/QualityCertificateEdit.aspx.cs

238 lines
9.6 KiB
C#

using System;
using System.Linq;
using BLL;
namespace FineUIPro.Web.HJGL.MaterialManage
{
public partial class QualityCertificateEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string QualityCertificateId
{
get
{
return (string)ViewState["QualityCertificateId"];
}
set
{
ViewState["QualityCertificateId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.QualityCertificateId = Request.Params["QualityCertificateId"];
StockInitService.InitWarrantybook(this.drpWarrantybook, true);
if (!string.IsNullOrEmpty(this.QualityCertificateId))
{
this.hdQualityCertificateId.Text = this.QualityCertificateId;
Model.Weld_QualityCertificate qc = BLL.QualityCertificateService.GetQualityCertificateByQualityCertificateId(this.QualityCertificateId);
if (qc != null)
{
if (!string.IsNullOrEmpty(qc.WeldId))
{
this.hdWeldId.Text = qc.WeldId;
var weld = BLL.WeldInfoService.GetWeldInfoById(qc.WeldId);
if (weld != null)
{
//this.txtWeldCode.Text = weld.WeldCode;
this.txtWeldName.Text = weld.WeldName;
this.txtWeldSpec.Text = weld.WeldSpec;
if (!string.IsNullOrEmpty(weld.WeldTypeId))
{
var weldType = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
if (weldType != null)
{
this.txtWeldType.Text = weldType.WeldTypeName;
}
}
}
this.drpWarrantybook.SelectedItem.Text = qc.Warrantybook;
this.txtHeartNo.Text = qc.HeartNo;
}
}
}
else
{
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.txtWeldName.Text.Trim() == string.Empty)
{
Alert.ShowInTop("请选择焊材牌号!", MessageBoxIcon.Warning);
return;
}
if (this.drpWarrantybook.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择入库自编号!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(this.hdQualityCertificateId.Text.Trim()))
{
Alert.ShowInTop("请上传质保书附件!", MessageBoxIcon.Warning);
return;
}
SaveData();
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 保存数据
/// </summary>
private void SaveData()
{
Model.Weld_QualityCertificate qc = new Model.Weld_QualityCertificate();
if (!string.IsNullOrEmpty(this.hdWeldId.Text.Trim()))
{
qc.WeldId = this.hdWeldId.Text.Trim();
}
qc.Warrantybook = drpWarrantybook.SelectedItem.Text.Trim();
//qc.Number = txtNumber.Text.Trim();
qc.HeartNo = this.txtHeartNo.Text.Trim();
qc.CompileMan = this.CurrUser.UserId;
qc.CompileDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.QualityCertificateId))
{
qc.QualityCertificateId = this.QualityCertificateId;
BLL.QualityCertificateService.UpdateQualityCertificate(qc);
BLL.Sys_LogService.AddLog(Const.System_7, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改焊材质保书");
}
else
{
if (string.IsNullOrWhiteSpace(this.hdQualityCertificateId.Text.Trim()))
{
qc.QualityCertificateId = SQLHelper.GetNewID(typeof(Model.Weld_QualityCertificate));
}
else
{
qc.QualityCertificateId = this.hdQualityCertificateId.Text.Trim();
}
BLL.QualityCertificateService.AddQualityCertificate(qc);
BLL.Sys_LogService.AddLog(Const.System_7, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加焊材质保书");
}
}
#endregion
#region
/// <summary>
/// 上传附件资源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl2_Click(object sender, EventArgs e)
{
string edit = "0"; // 表示能打开附件上传窗口,但不能上传附件
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_QualityCertificateMenuId, BLL.Const.BtnAdd))
{
if (string.IsNullOrEmpty(this.hdQualityCertificateId.Text.Trim()))
{
this.hdQualityCertificateId.Text = SQLHelper.GetNewID();
}
edit = "1";
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/WeldMat/QualityCertificate&menuId={1}&edit={2}", this.hdQualityCertificateId.Text, Const.CLGL_QualityCertificateMenuId, edit)));
}
}
#endregion
#region
/// <summary>
/// 查找焊材信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSelect_Click(object sender, EventArgs e)
{
string window = String.Format("../../WeldMat/Stock/ShowWeldInfo.aspx", "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdWeldId.ClientID) + Window1.GetShowReference(window));
}
#region
/// <summary>
/// 弹出编辑窗体关闭事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
if (!string.IsNullOrEmpty(this.hdWeldId.Text))
{
var weld = BLL.WeldInfoService.GetWeldInfoById(this.hdWeldId.Text);
if (weld != null)
{
//this.txtWeldCode.Text = weld.WeldCode;
this.txtWeldName.Text = weld.WeldName;
this.txtWeldSpec.Text = weld.WeldSpec;
if (!string.IsNullOrEmpty(weld.WeldTypeId))
{
var weldType = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
if (weldType != null)
{
this.txtWeldType.Text = weldType.WeldTypeName;
}
}
}
}
}
#endregion
#endregion
protected void drpWarrantybook_SelectedIndexChanged(object sender, EventArgs e)
{
this.txtHeartNo.Text = string.Empty;
this.txtWeldName.Text = string.Empty;
this.txtWeldSpec.Text = string.Empty;
this.txtWeldType.Text = string.Empty;
if (this.drpWarrantybook.SelectedValue != BLL.Const._Null)
{
this.txtHeartNo.Text = this.drpWarrantybook.SelectedValue.Split(',')[0];
Model.Weld_StockIn s = (from x in Funs.DB.Weld_StockIn where x.Warrantybook == this.drpWarrantybook.SelectedItem.Text.Trim() select x).FirstOrDefault();
if (s != null)
{
this.hdWeldId.Text = s.WeldId;
var weld = BLL.WeldInfoService.GetWeldInfoById(s.WeldId);
if (weld != null)
{
//this.txtWeldCode.Text = weld.WeldCode;
this.txtWeldName.Text = weld.WeldName;
this.txtWeldSpec.Text = weld.WeldSpec;
if (!string.IsNullOrEmpty(weld.WeldTypeId))
{
var weldType = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
if (weldType != null)
{
this.txtWeldType.Text = weldType.WeldTypeName;
}
}
}
}
}
}
}
}