SGGL_JT/SUBQHSE/FineUIPro.Web/ZHGL/FinalFileManage/SendAndAccepEdit.aspx.cs

363 lines
14 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FineUIPro.Web.ZHGL.FinalFileManage
{
public partial class SendAndAccepEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string FileId
{
get
{
return (string)ViewState["FileId"];
}
set
{
ViewState["FileId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
public string Fwtype
{
get
{
return (string)ViewState["Fwtype"];
}
set
{
ViewState["Fwtype"] = value;
}
}
#endregion
#region CustomClass
public class CustomClass
{
private string _id;
public string ID
{
get { return _id; }
set { _id = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
public CustomClass(string id, string name)
{
_id = id;
_name = name;
}
}
#endregion
/// <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();
FileId = Request.Params["FileId"];
Fwtype = Request.Params["Fwtype"];
if (Fwtype == "0")
{
//发文
List<CustomClass> myList = new List<CustomClass>();
myList.Add(new CustomClass("", "请选择"));
myList.Add(new CustomClass("0", "发文-集发"));
myList.Add(new CustomClass("1", "发文-集安发"));
myList.Add(new CustomClass("2", "发文-安便函"));
myList.Add(new CustomClass("3", "发文-通知"));
myList.Add(new CustomClass("10", "发文-风险提示函"));
myList.Add(new CustomClass("11", "发文-安全生产重大事项挂牌督办单"));
myList.Add(new CustomClass("12", "发文-其他"));
ddlFileType.DataTextField = "Name";
ddlFileType.DataValueField = "ID";
ddlFileType.DataSource = myList;
ddlFileType.DataBind();
btnSubmit.Text = "发送";
btnReply.Hidden=true;
}
else {
List<CustomClass> myList = new List<CustomClass>();
myList.Add(new CustomClass("", "请选择"));
myList.Add(new CustomClass("4", "收文-安发"));
myList.Add(new CustomClass("5", "收文-集安发"));
myList.Add(new CustomClass("6", "收文-集发"));
myList.Add(new CustomClass("7", "收文-通知"));
myList.Add(new CustomClass("8", "收文-集质环发"));
myList.Add(new CustomClass("9", "收文-集安全发"));
myList.Add(new CustomClass("13", "收文-其他"));
ddlFileType.DataTextField = "Name";
ddlFileType.DataValueField = "ID";
ddlFileType.DataSource = myList;
ddlFileType.DataBind();
drpUnit.Hidden = true;
drpProject.Hidden = true;
btnSubmit.Text = "发送";
}
//加载所有单位(公司级)
BLL.UnitService.InitNoThisAllUnitDownList(this.drpUnit, false);
UnitService.InitBranchUnitDropDownList(this.drpUnit, true, false);
if (!string.IsNullOrEmpty(this.FileId))
{
Model.FinalFileManage_SendAndAccep SendAndAccep = BLL.SendAndAccepService.GetSendAndAccepById(this.FileId);
if (SendAndAccep != null)
{
///读取编号
this.txtFileCode.Text = SendAndAccep.FileCode;
this.txtFileName.Text = SendAndAccep.FileName;
this.txtKeyWords.Text = SendAndAccep.KeyWords;
this.txtFileContent.Text = HttpUtility.HtmlDecode(SendAndAccep.FileContent);
this.txtReplyDatePlan.Text = string.Format("{0:yyyy-MM-dd}", SendAndAccep.ReplyDatePlan);
dpAddDate.Text = string.Format("{0:yyyy-MM-dd}", SendAndAccep.CompileDate);
this.ddlFileType.SelectedValue = SendAndAccep.FileType;
//单位 和 项目
if (!string.IsNullOrEmpty(SendAndAccep.UnitId))
{
this.drpUnit.SelectedValueArray = SendAndAccep.UnitId.Split(',');
}
loadProjectByUnits();
//BLL.ProjectService.InitUnitProjectDropDownList(this.drpProject, this.drpUnit.SelectedValue, true);
if (!string.IsNullOrEmpty(SendAndAccep.ProjectId))
{
this.drpProject.SelectedValueArray = SendAndAccep.ProjectId.Split(',');
}
// AddAttachTab();
}
}
else
{
var FileCodeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.SendAndAccepMenuId, this.ProjectId);
if (FileCodeTemplateRule != null)
{
this.txtFileContent.Text = HttpUtility.HtmlDecode(FileCodeTemplateRule.Template);
}
dpAddDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
private void AddAttachTab()
{
string Classify = "正文";
if (!string.IsNullOrEmpty(FileId))
{
Model.AttachFile file = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == FileId);
if (file != null && !string.IsNullOrEmpty(file.AttachUrl))
{
string url = file.AttachUrl.Replace('\\', '/');
url = url.Replace(Funs.RootPath, "").Replace("#", "%23");
// this.Tab1.IFrameUrl = "../../AttachFile/Look.aspx ?fileUrl=" + url;
}
}
}
// <summary>
/// 单位变化后加载项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void OndrpUnitChanged(object sender, EventArgs e)
{
loadProjectByUnits();
}
protected void loadProjectByUnits() {
var units = "";
for (int i = 0; i < drpUnit.SelectedValueArray.Length; i++)
{
if (drpUnit.SelectedValueArray[i] != Const._Null)
{
units += "" + drpUnit.SelectedValueArray[i] + ",";
}
}
if (units != "")
{
units = units.Substring(0, units.Length - 1);
BLL.ProjectService.InitUnitProjectDropDownListList(this.drpProject, units, true);
}
}
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.FileId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/SendAndAccepAttachUrl&menuId={1}", FileId, BLL.Const.SendAndAccepMenuId)));
}
protected void btnTest_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.FileId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/SendAndAccepAttachUrl&menuId={1}", FileId+"-test", BLL.Const.SendAndAccepMenuId)));
}
protected void btnReply_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.FileId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/SendAndAccepAttachUrl&menuId={1}", FileId + "-reply", BLL.Const.SendAndAccepMenuId)));
}
#endregion
#region
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSubmit_Click(object sender, EventArgs e)
{
//if (this.drpUnit.SelectedValue == Const._Null)
//{
// ShowNotify("请选择单位!", MessageBoxIcon.Warning);
// return;
//}
if (string.IsNullOrEmpty(this.ddlFileType.SelectedValue))
{
ShowNotify("请选择收发文类型!", MessageBoxIcon.Warning);
return;
}
this.SaveData(BLL.Const.BtnSubmit);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
//if (this.drpUnit.SelectedValue == Const._Null)
//{
// ShowNotify("请选择单位!", MessageBoxIcon.Warning);
// return;
//}
if (string.IsNullOrEmpty(this.ddlFileType.SelectedValue))
{
ShowNotify("请选择收发文类型!", MessageBoxIcon.Warning);
return;
}
this.SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
Model.FinalFileManage_SendAndAccep SendAndAccep = new Model.FinalFileManage_SendAndAccep
{
FileCode = this.txtFileCode.Text.Trim(),
FileName = this.txtFileName.Text.Trim(),
KeyWords = this.txtKeyWords.Text.Trim(),
UnitId = this.drpUnit.SelectedValue,
ProjectId = this.drpProject.SelectedValue,
ReplyDatePlan = Funs.GetNewDateTime(this.txtReplyDatePlan.Text.Trim()),
CompileMan = CurrUser.UserId,
CompileDate = Convert.ToDateTime(dpAddDate.Text),
FileType = ddlFileType.SelectedValue
};
SendAndAccep.FileContent = HttpUtility.HtmlEncode(this.txtFileContent.Text);
string unitIds = string.Empty;
var unitList = this.drpUnit.SelectedValueArray;
foreach (var item in unitList)
{
unitIds += item + ",";
}
if (!string.IsNullOrEmpty(unitIds))
{
unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
}
SendAndAccep.UnitId = unitIds;
string projectIds = string.Empty;
var projectList = this.drpProject.SelectedValueArray;
foreach (var item in projectList)
{
projectIds += item + ",";
}
if (!string.IsNullOrEmpty(projectIds))
{
projectIds = projectIds.Substring(0, projectIds.LastIndexOf(","));
}
SendAndAccep.ProjectId = projectIds;
if (type == "提交")
{
SendAndAccep.States = "1";
}
else {
SendAndAccep.States = "0";
}
if (!string.IsNullOrEmpty(this.FileId))
{
SendAndAccep.FileId = this.FileId;
BLL.SendAndAccepService.UpdateSendAndAccep(SendAndAccep);
BLL.LogService.AddSys_Log(this.CurrUser, SendAndAccep.FileCode, SendAndAccep.FileId, BLL.Const.SendAndAccepMenuId, BLL.Const.BtnModify);
}
else
{
this.FileId = SQLHelper.GetNewID(typeof(Model.FinalFileManage_SendAndAccep));
SendAndAccep.FileId = this.FileId;
BLL.SendAndAccepService.AddSendAndAccep(SendAndAccep);
BLL.LogService.AddSys_Log(this.CurrUser, SendAndAccep.FileCode, SendAndAccep.FileId, BLL.Const.SendAndAccepMenuId, BLL.Const.BtnAdd);
}
}
#endregion
}
}