196 lines
7.2 KiB
C#
196 lines
7.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.CQMS.Models
|
|
{
|
|
public partial class QualityModelEdit : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 页面加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
string id = Request.Params["QualityModelId"];
|
|
string year = DateTime.Now.Year.ToString();
|
|
if (!string.IsNullOrEmpty(Request.Params["type"]))
|
|
{
|
|
this.btnSave.Hidden = true;
|
|
}
|
|
CompanyModelService.InitModelTypeDownList(this.drpModelType, true);
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
Model.Model_QualityModel QualityModel = BLL.QualityModelService.GetQualityModelById(id);
|
|
if (QualityModel != null)
|
|
{
|
|
this.hdId.Text = id;
|
|
if (!string.IsNullOrEmpty(QualityModel.CompanyModelId))
|
|
{
|
|
this.drpModelType.SelectedValue = QualityModel.CompanyModelId;
|
|
}
|
|
if (!string.IsNullOrEmpty(QualityModel.Evaluate))
|
|
{
|
|
this.rblEvaluate.SelectedValue = QualityModel.Evaluate;
|
|
}
|
|
this.txtRemark.Text = QualityModel.Remark;
|
|
BindCGrid();
|
|
BindGrid();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 附件上传
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttach_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
|
|
{
|
|
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Model_QualityModel));
|
|
}
|
|
if (!string.IsNullOrEmpty(Request.Params["type"]))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/Models&menuId={1}", this.hdId.Text, BLL.Const.QualityModelMenuId)));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/Models&menuId={1}", this.hdId.Text, BLL.Const.QualityModelMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpModelType.SelectedValue == BLL.Const._Null)
|
|
{
|
|
ShowNotify("请选择样板类型!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.rblEvaluate.SelectedValue == BLL.Const._Null)
|
|
{
|
|
ShowNotify("请选择项目实物评价!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Request.Params["QualityModelId"];
|
|
Model.Model_QualityModel newQualityModel = new Model.Model_QualityModel();
|
|
newQualityModel.ProjectId = this.CurrUser.LoginProjectId;
|
|
newQualityModel.CompanyModelId = this.drpModelType.SelectedValue;
|
|
newQualityModel.Evaluate = this.rblEvaluate.SelectedValue;
|
|
newQualityModel.Remark = this.txtRemark.Text.Trim();
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
newQualityModel.QualityModelId = id;
|
|
BLL.QualityModelService.UpdateQualityModel(newQualityModel);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.hdId.Text))
|
|
{
|
|
newQualityModel.QualityModelId = this.hdId.Text.Trim();
|
|
}
|
|
else
|
|
{
|
|
newQualityModel.QualityModelId = SQLHelper.GetNewID(typeof(Model.Model_QualityModel));
|
|
this.hdId.Text = newQualityModel.QualityModelId;
|
|
}
|
|
newQualityModel.CompileMan = this.CurrUser.PersonId;
|
|
newQualityModel.CompileDate = DateTime.Now;
|
|
BLL.QualityModelService.AddQualityModel(newQualityModel);
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭弹出窗口
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
public void BindGrid()
|
|
{
|
|
string strSql = @"select * from AttachFile where ToKeyId='" + this.hdId.Text + "'";
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
public void BindCGrid()
|
|
{
|
|
if (this.drpModelType.SelectedValue != BLL.Const._Null)
|
|
{
|
|
string strSql = @"select * from AttachFile where ToKeyId='" + this.drpModelType.SelectedValue + "'";
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
|
GridC.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(GridC, tb);
|
|
GridC.DataSource = table;
|
|
GridC.DataBind();
|
|
}
|
|
else
|
|
{
|
|
GridC.DataSource = null;
|
|
GridC.DataBind();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取图片(放于Img中)
|
|
/// </summary>
|
|
/// <param name="registrationId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertImageUrlByImage(object CompanyModelId)
|
|
{
|
|
string url = string.Empty;
|
|
if (CompanyModelId != null)
|
|
{
|
|
var attachFile = BLL.AttachFileService.GetAttachFileByToKeyId(CompanyModelId.ToString());
|
|
if (attachFile != null)
|
|
{
|
|
url = HttpUtility.HtmlDecode(BLL.UploadAttachmentService.ShowImage("../../", attachFile.AttachUrl));
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
#endregion
|
|
|
|
protected void drpModelType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindCGrid();
|
|
}
|
|
}
|
|
} |