142 lines
6.0 KiB
C#
142 lines
6.0 KiB
C#
using System;
|
||
using BLL;
|
||
|
||
namespace FineUIPro.Web.common.ProjectSet
|
||
{
|
||
public partial class ProjectPictureEdit : PageBase
|
||
{
|
||
#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();
|
||
string projectPictureId = Request.Params["ProjectPictureId"];
|
||
if (!string.IsNullOrEmpty(projectPictureId))
|
||
{
|
||
Model.Project_ProjectPicture projectPicture = BLL.Project_ProjectPictureService.GetProjectPictureById(projectPictureId);
|
||
if (projectPicture != null)
|
||
{
|
||
this.txtProjectPictureCode.Text = projectPicture.ProjectPictureCode;
|
||
this.txtProjectPictureName.Text = projectPicture.ProjectPictureName;
|
||
if (projectPicture.CreateDate.HasValue)
|
||
{
|
||
this.txtCreateDate.Text = string.Format("{0:yyyy-MM-dd}", projectPicture.CreateDate);
|
||
}
|
||
if (projectPicture.IsShow == true)
|
||
{
|
||
this.cbIsShow.Checked = true;
|
||
}
|
||
else
|
||
{
|
||
this.cbIsShow.Checked = false;
|
||
}
|
||
this.txtRemark.Text = projectPicture.Remark;
|
||
if (!string.IsNullOrEmpty(projectPicture.AttachUrl))
|
||
{
|
||
imgPhoto.ImageUrl = projectPicture.AttachUrl;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
this.txtCreateDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||
}
|
||
}
|
||
}
|
||
#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.ProjectPictureMenuId, Const.BtnSave))
|
||
{
|
||
string projectPictureId = Request.Params["ProjectPictureId"];
|
||
Model.Project_ProjectPicture newProjectPicture = new Model.Project_ProjectPicture();
|
||
newProjectPicture.ProjectPictureCode = this.txtProjectPictureCode.Text.Trim();
|
||
newProjectPicture.ProjectPictureName = this.txtProjectPictureName.Text.Trim();
|
||
newProjectPicture.CreateDate = Funs.GetNewDateTime(this.txtCreateDate.Text.Trim());
|
||
if (this.cbIsShow.Checked == true)
|
||
{
|
||
newProjectPicture.IsShow = true;
|
||
}
|
||
else
|
||
{
|
||
newProjectPicture.IsShow = false;
|
||
}
|
||
newProjectPicture.Remark = this.txtRemark.Text.Trim();
|
||
newProjectPicture.AttachUrl = imgPhoto.ImageUrl;
|
||
if (!string.IsNullOrEmpty(projectPictureId))
|
||
{
|
||
newProjectPicture.ProjectPictureId = projectPictureId;
|
||
BLL.Project_ProjectPictureService.UpdateProjectPicture(newProjectPicture);
|
||
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectPictureMenuId, Const.BtnModify, projectPictureId);
|
||
}
|
||
else
|
||
{
|
||
projectPictureId = SQLHelper.GetNewID(typeof(Model.Project_ProjectPicture));
|
||
newProjectPicture.ProjectPictureId = projectPictureId;
|
||
BLL.Project_ProjectPictureService.AddProjectPicture(newProjectPicture);
|
||
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectPictureMenuId, Const.BtnAdd, projectPictureId);
|
||
}
|
||
|
||
ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
|
||
// 关闭本窗体,然后回发父窗体
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 上传图片
|
||
/// <summary>
|
||
/// 上传图片
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void filePhoto_FileSelected(object sender, EventArgs e)
|
||
{
|
||
if (filePhoto.HasFile)
|
||
{
|
||
string fileName = filePhoto.ShortFileName;
|
||
if (!ValidateFileType(fileName))
|
||
{
|
||
ShowNotify(Resources.Lan.InvalidFileType, MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
|
||
fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
|
||
filePhoto.SaveAs(Server.MapPath("~/upload/" + fileName));
|
||
imgPhoto.ImageUrl = "~/upload/" + fileName;
|
||
// 清空文件上传组件
|
||
filePhoto.Reset();
|
||
|
||
//截取图片格式,如果是jpg格式,勾选是否显示,否则不勾选
|
||
string imgFormat = fileName.Substring(fileName.LastIndexOf('.'));
|
||
if (imgFormat == ".jpg")
|
||
{
|
||
this.cbIsShow.Checked = true;
|
||
}
|
||
else
|
||
{
|
||
this.cbIsShow.Checked = false;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |