784 lines
32 KiB
C#
784 lines
32 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using BLL;
|
|
using MiniExcelLibs;
|
|
|
|
namespace FineUIPro.Web.ZHGL.FinalFileManage
|
|
{
|
|
public partial class SendAndAccep : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 页面类型 0.发送文件 1.接收文件
|
|
/// </summary>
|
|
public string Type
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Type"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Type"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 访问类型 0.公司级 1.项目级
|
|
/// </summary>
|
|
public string TypesOf
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["TypesOf"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["TypesOf"] = value;
|
|
}
|
|
}
|
|
public static DataTable dataTable;
|
|
#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
|
|
|
|
protected string ConvertType(object fwtypes)
|
|
{
|
|
var fwtype = fwtypes.ToString();
|
|
switch (fwtype)
|
|
{
|
|
case "0":
|
|
return "发文-集发";
|
|
case "1":
|
|
return "发文-集安发";
|
|
case "2":
|
|
return "发文-安便函";
|
|
case "3":
|
|
return "发文-通知";
|
|
case "4":
|
|
return "收文-安发";
|
|
case "5":
|
|
return "收文-集安发";
|
|
case "6":
|
|
return "收文-集办法";
|
|
case "7":
|
|
return "收文-通知";
|
|
case "8":
|
|
return "收文-集质环发";
|
|
case "9":
|
|
return "收文-集安全发";
|
|
|
|
case "10":
|
|
return "发文-风险提示函";
|
|
case "11":
|
|
return "发文-安全生产重大事项挂牌督办单";
|
|
case "12":
|
|
return "发文-其他";
|
|
case "13":
|
|
return "收文-其他";
|
|
}
|
|
return "";
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Type = Request.Params["Type"];
|
|
if (Type == "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();
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
GridColumn column = Grid1.FindColumn("UnitName");
|
|
column.HeaderText = "收文类型";
|
|
GridColumn column2 = Grid1.FindColumn("CompileDate");
|
|
column2.HeaderText = "收文时间";
|
|
|
|
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();
|
|
}
|
|
TypesOf = Request.Params["TypesOf"];
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
if (Type == "0")
|
|
{
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("SendAndAccepEdit.aspx?Fwtype=0") + "return false;";
|
|
}
|
|
else
|
|
{
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("SendAndAccepEdit.aspx?Fwtype=1") + "return false;";
|
|
}
|
|
if (TypesOf == "1")
|
|
{
|
|
this.btnNew.Hidden = true;
|
|
}
|
|
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
{
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
|
|
txtMonth.Text = DateTime.Now.Year.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var menuid = "";
|
|
if (Type == "0")
|
|
{
|
|
if (TypesOf == "0")
|
|
{
|
|
menuid = Const.SendAndAccepMenuId;
|
|
}
|
|
else
|
|
{
|
|
menuid = Const.SendAndAccepMenuId_xm;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (TypesOf == "0")
|
|
{
|
|
menuid = Const.SendAndAccepMenuId_r;
|
|
}
|
|
else
|
|
{
|
|
menuid = Const.SendAndAccepMenuId_r_xm;
|
|
}
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, menuid);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
}
|
|
if (Type == "0")
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
//接收文件隐藏修改、新增按钮、删除按钮
|
|
//this.btnNew.Hidden = true;
|
|
//this.btnMenuEdit.Hidden = true;
|
|
//this.btnMenuDelete.Hidden = true;
|
|
//显示回复按钮
|
|
|
|
}
|
|
|
|
if (CurrUser.UserId == Const.sysglyId || CurrUser.UserId == Const.hfnbdId)
|
|
{
|
|
btnMenuUpdateState.Hidden = false;
|
|
}
|
|
else if (CurrUser.UnitId == "A26E718E-C3B3-458E-A5A3-D2568A0F7D49")
|
|
{
|
|
btnMenuUpdateState.Hidden = false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
//只有集团公司能看到
|
|
if (BLL.CommonService.IsMainUnitOrAdmin(this.CurrUser.UserId))
|
|
{
|
|
string strSql = @"SELECT FileId,F.UnitId,F.ProjectId,FileCode,FileName,KeyWords,CompileMan,CompileDate,ReplyDatePlan,ReplyDateReal,
|
|
ReplyContent,CompileManUser.UserName AS CompileManName,U.UnitName,P.ProjectName,F.FileType,
|
|
CASE WHEN States='0' then '待发送' when States='1' then '待回复' when States='2' then '已回复' END as StatesNr,F.States
|
|
|
|
FROM FinalFileManage_SendAndAccep as F
|
|
|
|
LEFT JOIN Sys_User AS CompileManUser ON F.CompileMan =CompileManUser.UserId
|
|
LEFT JOIN Base_Unit AS U ON F.unitid=U.UnitId
|
|
LEFT JOIN Base_project AS P ON F.projectid=P.ProjectId WHERE 1=1 ";
|
|
|
|
var userId = CurrUser.UserId;
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
#region 条件语句
|
|
bool UnitBol = false;
|
|
//不是本公司
|
|
if (CurrUser.UnitId != "A26E718E-C3B3-458E-A5A3-D2568A0F7D49")
|
|
{
|
|
UnitBol = true;
|
|
}
|
|
|
|
//不是管理员只看到自己编制的文件
|
|
if (Type == "0")
|
|
{
|
|
//发送文件页面
|
|
//管理员可以看到所有发文
|
|
//strSql += " and (F.FileType='0' or F.FileType='1' or F.FileType='2' or F.FileType='3') ";
|
|
|
|
if (userId == Const.sysglyId || userId == Const.hfnbdId)
|
|
{
|
|
//管理员可以看到所有发文
|
|
strSql += " and (F.FileType='0' or F.FileType='1' or F.FileType='2' or F.FileType='3' or F.FileType='10' or F.FileType='11') ";
|
|
}
|
|
else
|
|
{
|
|
strSql += " and (F.FileType='0' or F.FileType='1' or F.FileType='2' or F.FileType='3' or F.FileType='10' or F.FileType='11') ";
|
|
//不是管理员只能看到自己编制的 或者是自己的
|
|
//公司级
|
|
if (TypesOf == "0" && UnitBol)
|
|
{
|
|
//能看到接收人是自己的
|
|
strSql += " and (F.UnitId like '%" + CurrUser.UnitId + "%' or CompileMan = @CompileMan ) ";
|
|
listStr.Add(new SqlParameter("@CompileMan", CurrUser.UserId));
|
|
}
|
|
else if (TypesOf == "1" && UnitBol)
|
|
{
|
|
//项目级
|
|
//只能看到单位id或者项目id同时是自己的数据
|
|
strSql += " and (F.UnitId like '%" + CurrUser.UnitId + "%' or F.ProjectId like '%" + CurrUser.LoginProjectId + "%' or CompileMan = @CompileMan) ";
|
|
listStr.Add(new SqlParameter("@CompileMan", CurrUser.UserId));
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
strSql += " and (F.FileType='4' or F.FileType='5' or F.FileType='6' or F.FileType='7' or F.FileType='8' or F.FileType='9') ";
|
|
|
|
////接收页面
|
|
if (userId == Const.sysglyId || userId == Const.hfnbdId)
|
|
{
|
|
//管理员可以看到所有收文
|
|
strSql += " and (F.FileType='4' or F.FileType='5' or F.FileType='6' or F.FileType='7' or F.FileType='8' or F.FileType='9') ";
|
|
}
|
|
else
|
|
{
|
|
strSql += " and (F.FileType='4' or F.FileType='5' or F.FileType='6' or F.FileType='7' or F.FileType='8' or F.FileType='9') ";
|
|
//不是管理员或者本公司只能看到自己编制的 或者是自己的
|
|
|
|
|
|
//公司级
|
|
if (TypesOf == "0" && UnitBol)
|
|
{
|
|
//能看到接收人是自己的
|
|
strSql += " and (F.UnitId like '%" + CurrUser.UnitId + "%' or CompileMan = @CompileMan ) ";
|
|
listStr.Add(new SqlParameter("@CompileMan", CurrUser.UserId));
|
|
}
|
|
else if (TypesOf == "1" && UnitBol)
|
|
{
|
|
//项目级
|
|
//只能看到单位id或者项目id同时是自己的数据
|
|
strSql += " and (F.UnitId like '%" + CurrUser.UnitId + "%' or F.ProjectId like '%" + CurrUser.LoginProjectId + "%' or CompileMan = @CompileMan) ";
|
|
listStr.Add(new SqlParameter("@CompileMan", CurrUser.UserId));
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtFileCode.Text.Trim()))
|
|
{
|
|
strSql += " AND F.FileCode LIKE @FileCode";
|
|
listStr.Add(new SqlParameter("@FileCode", "%" + this.txtFileCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtFileName.Text.Trim()))
|
|
{
|
|
strSql += " AND F.FileName LIKE @FileName";
|
|
listStr.Add(new SqlParameter("@FileName", "%" + this.txtFileName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtKeyWords.Text.Trim()))
|
|
{
|
|
strSql += " AND F.KeyWords LIKE @KeyWords";
|
|
listStr.Add(new SqlParameter("@KeyWords", "%" + this.txtKeyWords.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(ckStates.SelectedValue))
|
|
{
|
|
strSql += " AND F.States = @States";
|
|
listStr.Add(new SqlParameter("@States", ckStates.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(ddlFileType.SelectedValue))
|
|
{
|
|
strSql += " AND F.FileType = @FileType";
|
|
listStr.Add(new SqlParameter("@FileType", ddlFileType.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(txtMonth.Text))
|
|
{
|
|
strSql += " AND Year(F.CompileDate) = '" + txtMonth.Text + "'";
|
|
|
|
}
|
|
#endregion
|
|
|
|
strSql += " order by CompileDate desc";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
dataTable = tb;
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
}
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 获取单位名称
|
|
/// </summary>
|
|
/// <param name="CarryUnitIds"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertCarryUnit(object CarryUnitIds)
|
|
{
|
|
string CarryUnitName = string.Empty;
|
|
if (CarryUnitIds != null)
|
|
{
|
|
string[] Ids = CarryUnitIds.ToString().Split(',');
|
|
foreach (string t in Ids)
|
|
{
|
|
var type = BLL.UnitService.GetUnitByUnitId(t);
|
|
if (type != null)
|
|
{
|
|
CarryUnitName += type.UnitName + ",";
|
|
}
|
|
}
|
|
}
|
|
if (CarryUnitName != string.Empty)
|
|
{
|
|
return CarryUnitName.Substring(0, CarryUnitName.Length - 1);
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var FinalFileManage = BLL.SendAndAccepService.GetSendAndAccepById(id);
|
|
if (FinalFileManage != null)
|
|
{
|
|
if (Type == "0")
|
|
{
|
|
var userId = CurrUser.UserId;
|
|
//如果是发文件页面,状态是待发送的:编辑,
|
|
if (FinalFileManage.States == "0")
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepEdit.aspx?FileId={0}&Fwtype=0", id, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
////否则是查看页面
|
|
//this.Window1.Title = "详情";
|
|
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}", id, "查看 - ")));
|
|
//公司级
|
|
if (TypesOf == "0")
|
|
{
|
|
if (userId == Const.sysglyId || userId == Const.hfnbdId)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Fwtype=0", id, "查看 - "), "查看"));
|
|
}
|
|
else if (FinalFileManage.States == "1" && (
|
|
//接收文件页面,待接收,并且接收人是自己,接收项目是空的:回复页面。
|
|
(FinalFileManage.UnitId.IndexOf(CurrUser.UnitId) != -1 && string.IsNullOrEmpty(FinalFileManage.ProjectId)) || (userId == Const.sysglyId || userId == Const.hfnbdId)))
|
|
{
|
|
this.Window1.Title = "回复";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Type=1&Fwtype=0", id, "回复 - "), "回复"));
|
|
}
|
|
else
|
|
{
|
|
//否则是查看页面
|
|
this.Window1.Title = "详情";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Fwtype=0", id, "查看 - "), "查看"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//项目级
|
|
//接收文件页面,待接收,并且接收人是自己,接收项目是自己:回复页面。
|
|
if (userId == Const.sysglyId || userId == Const.hfnbdId)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Fwtype=0", id, "查看 - "), "查看"));
|
|
}
|
|
else if (FinalFileManage.States == "1" && (
|
|
(FinalFileManage.UnitId.IndexOf(CurrUser.UnitId) != -1 && FinalFileManage.ProjectId == CurrUser.LoginProjectId) || (userId == Const.sysglyId || userId == Const.hfnbdId)))
|
|
{
|
|
this.Window1.Title = "回复";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Type=1&Fwtype=0", id, "回复 - "), "回复"));
|
|
}
|
|
else
|
|
{
|
|
//否则是查看页面
|
|
this.Window1.Title = "详情";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Fwtype=0", id, "查看 - "), "查看"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var userId = CurrUser.UserId;
|
|
//公司级
|
|
//如果是发文件页面,状态是待发送的:编辑,
|
|
if (FinalFileManage.States == "0")
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepEdit.aspx?FileId={0}&Fwtype=1", id, "编辑 - "), "编辑"));
|
|
}
|
|
else
|
|
{
|
|
////否则是查看页面
|
|
//this.Window1.Title = "详情";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}", id, "查看 - "), "查看"));
|
|
//公司级
|
|
//if (TypesOf == "0")
|
|
//{
|
|
// //接收文件页面,待接收,并且接收人是自己,接收项目是空的:回复页面。
|
|
// if (FinalFileManage.States == "1" && (
|
|
// (FinalFileManage.UnitId == CurrUser.UnitId && string.IsNullOrEmpty(FinalFileManage.ProjectId)) || (userId == Const.sysglyId || userId == Const.hfnbdId)))
|
|
// {
|
|
// this.Window1.Title = "回复";
|
|
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Type=1&Fwtype=1", id, "回复 - ")));
|
|
// }
|
|
// else
|
|
// {
|
|
// //否则是查看页面
|
|
// this.Window1.Title = "详情";
|
|
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Fwtype=1", id, "查看 - ")));
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// //项目级
|
|
// //接收文件页面,待接收,并且接收人是自己,接收项目是自己:回复页面。
|
|
// if (FinalFileManage.States == "1" && (
|
|
// (FinalFileManage.UnitId == CurrUser.UnitId && FinalFileManage.ProjectId == CurrUser.LoginProjectId) || (userId == Const.sysglyId || userId == Const.hfnbdId)))
|
|
// {
|
|
// this.Window1.Title = "回复";
|
|
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepView.aspx?FileId={0}&Type=1&Fwtype=1", id, "回复 - ")));
|
|
// }
|
|
// else
|
|
// {
|
|
// //否则是查看页面
|
|
// this.Window1.Title = "详情";
|
|
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SendAndAccepEdit.aspx?FileId={0}&Fwtype=1", id, "查看 - ")));
|
|
// }
|
|
//}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
var menuid = "";
|
|
if (Type == "0")
|
|
menuid = Const.SendAndAccepMenuId;
|
|
else
|
|
menuid = Const.SendAndAccepMenuId_r;
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var getV = BLL.SendAndAccepService.GetSendAndAccepById(rowID);
|
|
if (getV != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, getV.FileCode, rowID, menuid, BLL.Const.BtnDelete);
|
|
BLL.SendAndAccepService.DeleteSendAndAccepById(rowID);
|
|
}
|
|
}
|
|
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void btnMenuUpdate(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var model = Funs.DB.FinalFileManage_SendAndAccep.FirstOrDefault(x => x.FileId == id);
|
|
if (model != null)
|
|
{
|
|
if (model.States == "2")
|
|
{
|
|
model.States = "1";
|
|
}
|
|
else if (model.States == "1")
|
|
{
|
|
model.States = "2";
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("当前数据不允许修改状态!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Alert.ShowInTop("修改成功", MessageBoxIcon.Success);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Print();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
void Print()
|
|
{
|
|
string path = Funs.RootPath + @"File\Excel\Temp\SendAndAccep" + string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx";
|
|
|
|
var filetypelist = dataTable.AsEnumerable().Select(x => new
|
|
{
|
|
FileType = x.Field<string>("FileType")
|
|
}).Distinct();
|
|
|
|
|
|
string fileName = string.Empty;
|
|
if (Type == "0")
|
|
{
|
|
fileName = "发文台账.xlsx";
|
|
}
|
|
else
|
|
{
|
|
fileName = "收文台账.xlsx";
|
|
}
|
|
var sheets = new DataSet();
|
|
string[] Send = new string[] { "0", "1", "2", "3", "10", "11" };
|
|
string[] Accep = new string[] { "4", "5", "6", "7", "8", "9" };
|
|
foreach (var item in filetypelist)
|
|
{
|
|
if (Send.Contains(item.FileType))
|
|
{
|
|
var result = dataTable.AsEnumerable().Where(x => x.Field<string>("FileType") == item.FileType).Select(x => new
|
|
{
|
|
|
|
文档编号 = x.Field<string>("FileCode"),
|
|
文档名称 = x.Field<string>("FileName"),
|
|
发文时间 = x.Field<DateTime?>("CompileDate"),
|
|
需反馈时间 = x.Field<DateTime?>("ReplyDatePlan"),
|
|
//发文时间 = string.Format("{0:yyyy-MM-dd}", x.Field<DateTime>("CompileDate")) ,
|
|
//需反馈时间 = string.Format("{0:yyyy-MM-dd}", x.Field<DateTime>("ReplyDatePlan")),
|
|
关键字 = x.Field<string>("KeyWords"),
|
|
备注 = ""
|
|
}).ToList();
|
|
var tb = Funs.LINQToDataTable(result);
|
|
tb.TableName = ConvertType(item.FileType);
|
|
sheets.Tables.Add(tb);
|
|
}
|
|
if (Accep.Contains(item.FileType))
|
|
{
|
|
var result = dataTable.AsEnumerable().Where(x => x.Field<string>("FileType") == item.FileType).Select(x => new
|
|
{
|
|
|
|
文档编号 = x.Field<string>("FileCode"),
|
|
文档名称 = x.Field<string>("FileName"),
|
|
来文单位 = x.Field<string>("UnitName"),
|
|
来文时间 = x.Field<DateTime?>("CompileDate"),
|
|
主要内容摘要 = x.Field<string>("KeyWords"),
|
|
是否反馈 = x.Field<string>("States") == "已回复" ? "是" : "否",
|
|
反馈日期 = x.Field<DateTime?>("ReplyDatePlan"),
|
|
是否落实 = "",
|
|
备注 = ""
|
|
}).ToList();
|
|
var tb = Funs.LINQToDataTable(result);
|
|
tb.TableName = ConvertType(item.FileType);
|
|
sheets.Tables.Add(tb);
|
|
}
|
|
}
|
|
|
|
MiniExcel.SaveAs(path, sheets);
|
|
|
|
FileInfo info = new FileInfo(path);
|
|
long fileSize = info.Length;
|
|
System.Web.HttpContext.Current.Response.Clear();
|
|
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
|
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
|
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
|
|
System.Web.HttpContext.Current.Response.Flush();
|
|
System.Web.HttpContext.Current.Response.Close();
|
|
File.Delete(path);
|
|
|
|
}
|
|
}
|
|
} |