159 lines
6.0 KiB
C#
159 lines
6.0 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.BaseInfo
|
|
{
|
|
public partial class CompanyModelEdit : 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["CompanyModelId"];
|
|
string year = DateTime.Now.Year.ToString();
|
|
if (!string.IsNullOrEmpty(Request.Params["type"]))
|
|
{
|
|
this.btnSave.Hidden = true;
|
|
}
|
|
CompanyModelKindService.InitCompanyModelKindDownList(this.drpCompanyModelKindId,true);
|
|
this.drpCompanyModelKindId.SelectedValue = BLL.Const._Null;
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
Model.Base_CompanyModel CompanyModel = BLL.CompanyModelService.GetCompanyModelById(id);
|
|
if (CompanyModel != null)
|
|
{
|
|
this.hdId.Text = id;
|
|
if (!string.IsNullOrEmpty(CompanyModel.CompanyModelKindId))
|
|
{
|
|
this.drpCompanyModelKindId.SelectedValue = CompanyModel.CompanyModelKindId;
|
|
}
|
|
this.txtModelType.Text = CompanyModel.ModelType;
|
|
this.txtRemark.Text = CompanyModel.Remark;
|
|
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.Base_CompanyModel));
|
|
}
|
|
if (!string.IsNullOrEmpty(Request.Params["type"]))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/Base/CompanyModel&menuId={1}", this.hdId.Text, BLL.Const.CompanyModelMenuId)));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/Base/CompanyModel&menuId={1}", this.hdId.Text, BLL.Const.CompanyModelMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpCompanyModelKindId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
ShowNotify("请选择样板类别!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Request.Params["CompanyModelId"];
|
|
Model.Base_CompanyModel newCompanyModel = new Model.Base_CompanyModel();
|
|
newCompanyModel.CompanyModelKindId = this.drpCompanyModelKindId.SelectedValue;
|
|
newCompanyModel.ModelType = this.txtModelType.Text.Trim();
|
|
newCompanyModel.Remark = this.txtRemark.Text.Trim();
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
newCompanyModel.CompanyModelId = id;
|
|
BLL.CompanyModelService.UpdateCompanyModel(newCompanyModel);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.hdId.Text))
|
|
{
|
|
newCompanyModel.CompanyModelId = this.hdId.Text.Trim();
|
|
}
|
|
else
|
|
{
|
|
newCompanyModel.CompanyModelId = SQLHelper.GetNewID(typeof(Model.Base_CompanyModel));
|
|
this.hdId.Text = newCompanyModel.CompanyModelId;
|
|
}
|
|
BLL.CompanyModelService.AddCompanyModel(newCompanyModel);
|
|
}
|
|
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>
|
|
/// 获取图片(放于Img中)
|
|
/// </summary>
|
|
/// <param name="registrationId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertImageUrlByImage(object CompanyModelId)
|
|
{
|
|
string url = string.Empty;
|
|
if (CompanyModelId != null)
|
|
{
|
|
var attachFile = BLL.AttachFileService.GetAttachFile(CompanyModelId.ToString(), BLL.Const.CompanyModelMenuId);
|
|
if (attachFile != null)
|
|
{
|
|
url = HttpUtility.HtmlDecode(BLL.UploadAttachmentService.ShowImage("../", attachFile.AttachUrl));
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
#endregion
|
|
}
|
|
} |