252 lines
10 KiB
C#
252 lines
10 KiB
C#
using BLL;
|
|
using BLL.CQMS.Comprehensive;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.Comprehensive
|
|
{
|
|
public partial class DataReceivingEdit : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string DataReceivingId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["DataReceivingId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["DataReceivingId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();
|
|
this.DataReceivingId = Request.Params["DataReceivingId"];
|
|
BLL.UnitService.InitUnitDownList(this.drpUnitIds, this.CurrUser.LoginProjectId, false);
|
|
|
|
this.btnSave.Hidden = true;
|
|
Model.Comprehensive_DataReceiving dataReceiving = BLL.DataReceivingService.GetDataReceivingById(this.DataReceivingId);
|
|
if (dataReceiving != null)
|
|
{
|
|
this.DataReceivingId = dataReceiving.DataReceivingId;
|
|
this.hdAttachUrl.Text = this.DataReceivingId;
|
|
this.txtFileCode.Text = dataReceiving.FileCode;
|
|
this.txtFileName.Text = dataReceiving.FileName;
|
|
if (dataReceiving.DataReceivingDate != null)
|
|
{
|
|
this.txtDataReceivingDate.Text = string.Format("{0:yyyy-MM-dd}", dataReceiving.DataReceivingDate);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(dataReceiving.SendUnit))
|
|
{
|
|
this.drpUnitIds.SelectedValueArray = dataReceiving.SendUnit.Split(',');
|
|
}
|
|
|
|
this.txtSendMan.Text = dataReceiving.SendMan;
|
|
if (!string.IsNullOrEmpty(dataReceiving.FileType))
|
|
{
|
|
this.drpFileType.SelectedValue = dataReceiving.FileType;
|
|
}
|
|
if (dataReceiving.CopiesCount != null)
|
|
{
|
|
this.txtCopiesCount.Text = Convert.ToString(dataReceiving.CopiesCount);
|
|
}
|
|
this.txtReceivingMan.Text = dataReceiving.ReceivingMan;
|
|
this.txtFileHandler.Text = dataReceiving.FileHandler;
|
|
if (dataReceiving.IsReply == true)
|
|
{
|
|
this.rblIsReply.SelectedValue = "true";
|
|
}
|
|
else
|
|
{
|
|
this.rblIsReply.SelectedValue = "false";
|
|
}
|
|
this.txtRemark.Text = dataReceiving.Remark;
|
|
|
|
|
|
var currApprove = DataReceivingApproveService.GetCurrentApprove(dataReceiving.DataReceivingId);
|
|
if (currApprove != null)
|
|
{ //重新编制 编制人 可以 显示 提交 保存按钮
|
|
if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && dataReceiving.CompileMan == CurrUser.UserId)
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}//审核状态 审核人 可以显示 提交 保存按钮
|
|
else if (currApprove.ApproveType == BLL.Const.Comprehensive_Audit && currApprove.ApproveMan == CurrUser.UserId)
|
|
{
|
|
//审核状态不可编辑
|
|
Readonly();
|
|
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}//没有当前审核人,已完成状态 或者 待提交状态
|
|
else
|
|
{
|
|
if (dataReceiving.Status == BLL.Const.Comprehensive_Compile && dataReceiving.CompileMan == CurrUser.UserId)
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
else {
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 禁止编辑
|
|
/// </summary>
|
|
public void Readonly()
|
|
{
|
|
this.txtCopiesCount.Readonly = true;
|
|
this.txtDataReceivingDate.Readonly = true;
|
|
|
|
this.txtReceivingMan.Readonly = true;
|
|
this.txtRemark.Readonly = true;
|
|
this.txtSendMan.Readonly = true;
|
|
this.drpFileType.Readonly = true;
|
|
this.drpUnitIds.Readonly = true;
|
|
//this.btnAttach.Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
#region 保存
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
Model.Comprehensive_DataReceiving dataReceiving = new Model.Comprehensive_DataReceiving();
|
|
dataReceiving.ProjectId = this.CurrUser.LoginProjectId;
|
|
dataReceiving.FileCode = this.txtFileCode.Text.Trim();
|
|
dataReceiving.FileName = this.txtFileName.Text.Trim();
|
|
dataReceiving.DataReceivingDate = Funs.GetNewDateTime(this.txtDataReceivingDate.Text);
|
|
dataReceiving.SendMan = this.txtSendMan.Text.Trim();
|
|
dataReceiving.FileType = this.drpFileType.SelectedValue;
|
|
dataReceiving.CopiesCount = Funs.GetNewInt(this.txtCopiesCount.Text.Trim());
|
|
dataReceiving.ReceivingMan = this.txtReceivingMan.Text.Trim();
|
|
dataReceiving.FileHandler = this.txtFileHandler.Text.Trim();
|
|
dataReceiving.IsReply = Convert.ToBoolean(this.rblIsReply.SelectedValue);
|
|
dataReceiving.Remark = this.txtRemark.Text.Trim();
|
|
string unitIds = string.Empty;
|
|
var unitList = this.drpUnitIds.SelectedValueArray;
|
|
foreach (var item in unitList)
|
|
{
|
|
unitIds += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(unitIds))
|
|
{
|
|
unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
|
|
}
|
|
dataReceiving.SendUnit = unitIds;
|
|
if (string.IsNullOrEmpty(this.DataReceivingId))
|
|
{
|
|
if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
|
|
{
|
|
dataReceiving.DataReceivingId = this.hdAttachUrl.Text;
|
|
}
|
|
else
|
|
{
|
|
dataReceiving.DataReceivingId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataReceiving));
|
|
this.hdAttachUrl.Text = dataReceiving.DataReceivingId;
|
|
}
|
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == dataReceiving.DataReceivingId);
|
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
dataReceiving.CompileMan = this.CurrUser.UserId;
|
|
dataReceiving.CompileDate = DateTime.Now;
|
|
dataReceiving.Status = Const.Comprehensive_Compile;
|
|
BLL.DataReceivingService.AddDataReceiving(dataReceiving);
|
|
}
|
|
else
|
|
{
|
|
dataReceiving.DataReceivingId = this.DataReceivingId;
|
|
Model.Comprehensive_DataReceiving model = BLL.DataReceivingService.GetDataReceivingById(this.DataReceivingId);
|
|
if (model != null)
|
|
{
|
|
dataReceiving.Status = model.Status;
|
|
}
|
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.DataReceivingId);
|
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
BLL.DataReceivingService.UpdateDataReceiving(dataReceiving);
|
|
}
|
|
|
|
|
|
|
|
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 附件上传
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttach_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录
|
|
{
|
|
this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataReceiving));
|
|
}
|
|
Model.Comprehensive_DataReceiving dataReceiving = BLL.DataReceivingService.GetDataReceivingById(this.DataReceivingId);
|
|
if (dataReceiving == null || ((dataReceiving.CompileMan == CurrUser.UserId && dataReceiving.Status == BLL.Const.Comprehensive_Compile) || (dataReceiving.CompileMan == CurrUser.UserId && dataReceiving.Status == BLL.Const.Comprehensive_ReCompile)))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/DataReceiving&menuId={1}", this.hdAttachUrl.Text, BLL.Const.DataReceivingMenuId)));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/DataReceiving&menuId={1}", this.hdAttachUrl.Text, BLL.Const.DataReceivingMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == BLL.Const._Null)
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DataReceivingMenuId);
|
|
if (buttonList.Count > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |