386 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			386 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Data;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using System.IO;
 | 
						|
using System.Linq;
 | 
						|
using System.Web;
 | 
						|
using System.Web.UI;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
 | 
						|
namespace FineUIPro.Web.DocManage
 | 
						|
{
 | 
						|
    public partial class DocManage : PageBase
 | 
						|
    {
 | 
						|
        #region 获取按钮权限
 | 
						|
        /// <summary>
 | 
						|
        /// 获取按钮权限
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="button"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        private void GetButtonPower()
 | 
						|
        {
 | 
						|
            if (Request.Params["value"] == "0")
 | 
						|
            {
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            var buttonList = CommonService.GetAllButtonList(CurrUser.LoginProjectId, CurrUser.UserId, Const.DocManageMenuId);
 | 
						|
            if (buttonList.Count() > 0)
 | 
						|
            {
 | 
						|
                if (buttonList.Contains(Const.BtnAdd))
 | 
						|
                {
 | 
						|
                    btnNew.Hidden = false;
 | 
						|
 | 
						|
                }
 | 
						|
                if (buttonList.Contains(Const.BtnModify))
 | 
						|
                {
 | 
						|
                    btnMenuModify.Hidden = false;
 | 
						|
                  //  btnPrint.Hidden = false;
 | 
						|
                }
 | 
						|
                if (buttonList.Contains(Const.BtnDelete))
 | 
						|
                {
 | 
						|
                    btnMenuDel.Hidden = false;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
        /// <summary>
 | 
						|
        /// 文档主键
 | 
						|
        /// </summary>
 | 
						|
        public string DocId
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                return (string)ViewState["DocId"];
 | 
						|
            }
 | 
						|
            set
 | 
						|
            {
 | 
						|
                ViewState["DocId"] = value;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 类型
 | 
						|
        /// </summary>
 | 
						|
        public string classify
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                return (string)ViewState["classify"];
 | 
						|
            }
 | 
						|
            set
 | 
						|
            {
 | 
						|
                ViewState["classify"] = value;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                classify = Request.Params["classify"];
 | 
						|
                UnitService.GetUnit(drpSendUnit, CurrUser.LoginProjectId, true);
 | 
						|
                UnitService.GetUnit(drpReceivUnit, CurrUser.LoginProjectId, true);
 | 
						|
                UserService.InitUserDropDownList(drpCompileMan, CurrUser.LoginProjectId, true);
 | 
						|
                UserService.InitUserDropDownList(drpAcceptMan, CurrUser.LoginProjectId, true);
 | 
						|
                DocTypeService.InitDocTypeDropDownList(drpDocType, true);
 | 
						|
                //CNProfessionalService.InitCNProfessionalDownList(drpCNProfessional, true);
 | 
						|
                DocManageService.InitDocState(this.drpState, true);
 | 
						|
                ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | 
						|
                btnNew.OnClientClick = Window1.GetShowReference("DocManageEdit.aspx") + "return false;";
 | 
						|
                GetButtonPower();
 | 
						|
                if (classify != "0")
 | 
						|
                {
 | 
						|
                    btnNew.Hidden = true;
 | 
						|
                }
 | 
						|
                BindData();
 | 
						|
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        private void BindData()
 | 
						|
        {
 | 
						|
            string strSql = @"SELECT doc.DocId,doc.ProjectId,doc.DocCode,doc.DocName,doc.ProjectSubjectId,unit.UnitName as SendUnitName,doc.ReceivUnitIds,docType.DocTypeName,"
 | 
						|
                          + @" doc.CompileMan,doc.CompileDate,CNProfessional.ProfessionalName,doc.State,u.userName"
 | 
						|
                          + @" FROM Doc_DocManage doc "
 | 
						|
                          + @" left join Base_Unit unit on unit.unitId=doc.SendUnitId "
 | 
						|
                          + @" left join Base_DocType docType on docType.DocTypeId=doc.DocTypeId "
 | 
						|
                          + @" left join Base_CNProfessional CNProfessional on CNProfessional.CNProfessionalId=doc.CNProfessionalId "
 | 
						|
                          + @" left join sys_User u on u.userId = doc.CompileMan"
 | 
						|
                          + @" where doc.ProjectId=@ProjectId";
 | 
						|
 | 
						|
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						|
            listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
 | 
						|
            strSql += " AND (doc.CompileDate>=@startTime or @startTime='') and (doc.CompileDate<=@endTime or @endTime='') ";
 | 
						|
            listStr.Add(new SqlParameter("@startTime", !string.IsNullOrEmpty(txtStartTime.Text.Trim()) ? txtStartTime.Text.Trim() + " 00:00:00" : ""));
 | 
						|
            listStr.Add(new SqlParameter("@endTime", !string.IsNullOrEmpty(txtEndTime.Text.Trim()) ? txtEndTime.Text.Trim() + " 23:59:59" : ""));
 | 
						|
            var unit = BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId);
 | 
						|
            if (unit != null && unit.UnitTypeId != BLL.Const.ProjectUnitType_4)
 | 
						|
            {
 | 
						|
                strSql += " AND (doc.ReceivUnitIds like @ReceivUnitId or doc.SendUnitId = @SendUnitId )";
 | 
						|
                if (string.IsNullOrEmpty(this.CurrUser.UnitId))
 | 
						|
                {
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                listStr.Add(new SqlParameter("@SendUnitId", this.CurrUser.UnitId));
 | 
						|
                listStr.Add(new SqlParameter("@ReceivUnitId", "%" + this.CurrUser.UnitId + "%"));
 | 
						|
            }
 | 
						|
            if (drpSendUnit.SelectedValue != Const._Null)
 | 
						|
            {
 | 
						|
                strSql += " AND doc.SendUnitId=@unitId";
 | 
						|
                listStr.Add(new SqlParameter("@unitId", drpSendUnit.SelectedValue));
 | 
						|
            }
 | 
						|
            if (drpReceivUnit.SelectedValue != Const._Null)
 | 
						|
            {
 | 
						|
                strSql += " AND doc.ReceivUnitIds like @unitId2";
 | 
						|
                listStr.Add(new SqlParameter("@unitId2", "%" + drpReceivUnit.SelectedValue + "%"));
 | 
						|
            }
 | 
						|
            if (drpDocType.SelectedValue != Const._Null)
 | 
						|
            {
 | 
						|
                strSql += " AND doc.DocTypeId=@DocTypeId";
 | 
						|
                listStr.Add(new SqlParameter("@DocTypeId", drpDocType.SelectedValue));
 | 
						|
            }
 | 
						|
            //if (drpCNProfessional.SelectedValue != Const._Null)
 | 
						|
            //{
 | 
						|
            //    strSql += " AND doc.CNProfessionalId=@CNProfessionalId ";
 | 
						|
            //    listStr.Add(new SqlParameter("@CNProfessionalId", drpCNProfessional.SelectedValue));
 | 
						|
            //}
 | 
						|
            if (drpState.SelectedValue != Const._Null)
 | 
						|
            {
 | 
						|
                strSql += " AND doc.State=@State";
 | 
						|
                listStr.Add(new SqlParameter("@State", drpState.SelectedValue));
 | 
						|
            }
 | 
						|
            if (drpCompileMan.SelectedValue != Const._Null)
 | 
						|
            {
 | 
						|
                strSql += " AND doc.CompileMan=@CompileMan";
 | 
						|
                listStr.Add(new SqlParameter("@CompileMan", drpCompileMan.SelectedValue));
 | 
						|
            }
 | 
						|
            if (drpAcceptMan.SelectedValue != Const._Null)
 | 
						|
            {
 | 
						|
                strSql += " AND doc.AcceptMan like @AcceptMan";
 | 
						|
                listStr.Add(new SqlParameter("@AcceptMan", "%" + drpAcceptMan.SelectedValue + "%"));
 | 
						|
            }
 | 
						|
            var uid = CurrUser.UserId;
 | 
						|
            //我创建的
 | 
						|
            if (classify == "0")
 | 
						|
            {
 | 
						|
                strSql += " AND doc.CompileMan ='" + uid + "' ";
 | 
						|
            }
 | 
						|
            //待我处理
 | 
						|
            else if (classify == "1")
 | 
						|
            {
 | 
						|
                strSql += " AND (doc.State ='1' and doc.AcceptMan like'%" + uid + "%'  )";
 | 
						|
            }
 | 
						|
            //我已处理
 | 
						|
            else if (classify == "2")
 | 
						|
            {
 | 
						|
                strSql += " AND (doc.State ='2' and doc.AcceptMan like'%" + uid + "%'  )";
 | 
						|
            }
 | 
						|
            //我参与的
 | 
						|
            else if (classify == "3")
 | 
						|
            {
 | 
						|
                strSql += " AND doc.CopyMan like'%" + uid + "%' ";
 | 
						|
            }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
            SqlParameter[] parameter = listStr.ToArray();
 | 
						|
            DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | 
						|
            tb = GetFilteredTable(Grid1.FilteredData, tb);
 | 
						|
            var table = GetPagedDataTable(Grid1, tb);
 | 
						|
            Grid1.RecordCount = tb.Rows.Count;
 | 
						|
            Grid1.DataSource = table;
 | 
						|
            Grid1.DataBind();
 | 
						|
            for (int i = 0; i < Grid1.Rows.Count; i++)
 | 
						|
            {
 | 
						|
                string rowID = Grid1.Rows[i].DataKeys[0].ToString();
 | 
						|
                Model.Doc_DocManage doc = BLL.DocManageService.GetDocByDocId(rowID);
 | 
						|
                if (doc != null)
 | 
						|
                {
 | 
						|
                    if (doc.State != BLL.Const.Doc_State_2 && doc.FinishTime.Value.AddDays(-1) == DateTime.Now.Date)
 | 
						|
                    {
 | 
						|
                        Grid1.Rows[i].CellCssClasses[8] = "Yellow";//未确认      
 | 
						|
                    }
 | 
						|
                    else if (doc.State != BLL.Const.Doc_State_2 && doc.FinishTime.Value < DateTime.Now.Date)
 | 
						|
                    {
 | 
						|
                        Grid1.Rows[i].CellCssClasses[8] = "Red";//未确认      
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 分页
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | 
						|
        {
 | 
						|
            //Grid1.PageIndex = e.NewPageIndex;
 | 
						|
            BindData();
 | 
						|
        }
 | 
						|
 | 
						|
/*        private void Print(string DocId)
 | 
						|
        {
 | 
						|
            var model = DocManageService.GetDocByDocId(DocId);
 | 
						|
            if (model.State != Const.Doc_State_2)
 | 
						|
            {
 | 
						|
                ShowNotify("当前状态未闭环无法打印", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            DataTable dt = new DataTable();
 | 
						|
            dt = DocManageApproveService.GetListData(DocId);
 | 
						|
            if (dt.Columns.Count == 0)
 | 
						|
            {
 | 
						|
                dt.Columns.Add("RoleName", typeof(String));
 | 
						|
                dt.Columns.Add("ApproveMan", typeof(String));
 | 
						|
                dt.Columns.Add("ApproveDate", typeof(String));
 | 
						|
                dt.Columns.Add("ApproveIdea", typeof(String));
 | 
						|
 | 
						|
            }
 | 
						|
            var keyValuePairs = BLL.DocManageService.GetPairs(DocId);
 | 
						|
            dt.TableName = "Table1";
 | 
						|
 | 
						|
            BLL.Common.FastReport.ResetData();
 | 
						|
            BLL.Common.FastReport.AddFastreportTable(dt);
 | 
						|
            BLL.Common.FastReport.AddFastreportParameter(keyValuePairs);
 | 
						|
            string initTemplatePath = "File/Fastreport/新疆文件管理流转表.frx";
 | 
						|
            string rootPath = Server.MapPath("~/");
 | 
						|
            if (File.Exists(rootPath + initTemplatePath))
 | 
						|
            {
 | 
						|
                PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
 | 
						|
 | 
						|
 | 
						|
            }
 | 
						|
        }*/
 | 
						|
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
 | 
						|
        {
 | 
						|
            string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
 | 
						|
            if (e.CommandName == "AttachUrl")
 | 
						|
            {
 | 
						|
                PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/DocManage&menuId={1}&type=-1", itemId, Const.DocManageMenuId)));
 | 
						|
 | 
						|
               // PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/Fileuploader.aspx?toKeyId={0}&path=FileUpload/DocManage&type=-1", itemId, "查看 - ")));
 | 
						|
            }/*
 | 
						|
            else if (e.CommandName == "Print")
 | 
						|
            {
 | 
						|
                Print(itemId);
 | 
						|
            }*/
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 分页显示条数下拉框
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | 
						|
            BindData();
 | 
						|
        }
 | 
						|
 | 
						|
        protected void btnQuery_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindData();
 | 
						|
        }
 | 
						|
 | 
						|
        protected void Window1_Close(object sender, WindowCloseEventArgs e)
 | 
						|
        {
 | 
						|
            BindData();
 | 
						|
        }
 | 
						|
 | 
						|
        protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | 
						|
        {
 | 
						|
            if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            DocId = Grid1.SelectedRowID.Split(',')[0];
 | 
						|
            Model.Doc_DocManage doc = DocManageService.GetDocByDocId(DocId);
 | 
						|
            Model.Doc_DocManageApprove approve = DocManageApproveService.GetDocManageApproveByDocId(DocId);
 | 
						|
 | 
						|
            if (doc.State == Const.Doc_State_2)
 | 
						|
            {
 | 
						|
                PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DocManageView.aspx?DocId={0}", DocId, "编辑 - ")));
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            if (approve != null)
 | 
						|
            {
 | 
						|
                if (!string.IsNullOrEmpty(approve.ApproveMan))
 | 
						|
                {
 | 
						|
                    if (CurrUser.UserId == approve.ApproveMan || CurrUser.UserId == Const.sysglyId || CurrUser.UserId == Const.hfnbdId)
 | 
						|
                    {
 | 
						|
                        PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DocManageEdit.aspx?DocId={0}", DocId, "编辑 - ")));
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        Alert.ShowInTop("您不是当前办理人,无法操作!", MessageBoxIcon.Warning);
 | 
						|
                        return;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("您不是当前办理人,无法操作!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        protected void btnMenuModify_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            Grid1_RowDoubleClick(null, null);
 | 
						|
        }
 | 
						|
        /*protected void btnbtnPrint_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            DocId = Grid1.SelectedRowID.Split(',')[0];
 | 
						|
            Print(DocId);
 | 
						|
        }*/
 | 
						|
        protected void btnMenuView_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            DocId = Grid1.SelectedRowID.Split(',')[0];
 | 
						|
            PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DocManageView.aspx?DocId={0}", DocId, "查看 - ")));
 | 
						|
        }
 | 
						|
 | 
						|
        protected void btnMenuDel_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            DocId = Grid1.SelectedRowID.Split(',')[0];
 | 
						|
            var code = DocManageService.GetDocByDocId(DocId).DocCode;
 | 
						|
            //BLL.AttachFileService.DeleteAttachFile(Funs.RootPath, DocId, Const.DocManageMenuId);//删除附件
 | 
						|
           // AttachFileDetailService.DeleteFileByToKeyId(DocId);//删除附件
 | 
						|
            DocManageApproveService.DeleteDocManageApprovesByDocId(DocId);
 | 
						|
            DocManageService.DeleteDoc(DocId);
 | 
						|
            LogService.AddSys_Log(CurrUser, code, DocId, Const.DocManageMenuId, "删除文档");
 | 
						|
            BindData();
 | 
						|
            Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
 | 
						|
        }
 | 
						|
 | 
						|
        protected void btnRset_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            txtStartTime.Text = "";
 | 
						|
            txtEndTime.Text = "";
 | 
						|
            drpSendUnit.SelectedIndex = 0;
 | 
						|
            drpReceivUnit.SelectedIndex = 0;
 | 
						|
            drpDocType.SelectedIndex = 0;
 | 
						|
            //drpCNProfessional.SelectedIndex = 0;
 | 
						|
            drpState.SelectedIndex = 0;
 | 
						|
            BindData();
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |