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 PersonalFileCabinet : PageBase { #region 页面加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); InitTreeMenu(); } } #endregion #region 加载树 /// /// 加载树 /// private void InitTreeMenu() { if (string.IsNullOrEmpty(this.CurrUser.UnitId)) { return; } this.tree1.Nodes.Clear(); this.tree1.ShowBorder = false; this.tree1.ShowHeader = false; this.tree1.EnableIcons = true; this.tree1.AutoScroll = true; this.tree1.EnableSingleClickExpand = true; if (RadioType.SelectedValue == "Unit") { List base_Unit = new List(); var list = BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId); //非业主 base_Unit.Add(list); foreach (var q in base_Unit) { TreeNode newNode = new TreeNode(); newNode.Text = q.UnitName; newNode.NodeID = q.UnitId; newNode.CommandName = "Unit"; newNode.EnableExpandEvent = true; newNode.EnableClickEvent = true; this.tree1.Nodes.Add(newNode); } } else { var DocTypeList = DocTypeService.GetDocTypeList(); foreach (var q in DocTypeList) { TreeNode newNode = new TreeNode(); newNode.Text = q.DocTypeName; newNode.NodeID = q.DocTypeId; newNode.EnableExpandEvent = true; newNode.EnableClickEvent = true; this.tree1.Nodes.Add(newNode); } } } #endregion #region Tree点击事件 /// /// Tree点击事件 /// /// /// protected void tree1_NodeCommand(object sender, TreeCommandEventArgs e) { BindGrid(); } #endregion protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// Grid1排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } private void BindGrid() { string strSql = @"SELECT doc.DocId,doc.ProjectId,doc.DocCode,doc.DocName,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 listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId)); if (RadioType.SelectedValue == "Unit" && !string.IsNullOrEmpty(tree1.SelectedNodeID)) { strSql += " AND doc.SendUnitId=@unitId"; listStr.Add(new SqlParameter("@unitId", tree1.SelectedNodeID)); } else if (RadioType.SelectedValue == "DocType" && !string.IsNullOrEmpty(tree1.SelectedNodeID)) { strSql += " AND doc.DocTypeId=@DocTypeId"; listStr.Add(new SqlParameter("@DocTypeId", tree1.SelectedNodeID)); } if (RadioList2.SelectedValue=="Send") { strSql += " AND doc.CompileMan=@CompileMan"; listStr.Add(new SqlParameter("@CompileMan", this.CurrUser.UserId)); } else { strSql += " AND doc.AcceptMan like @AcceptMan"; listStr.Add(new SqlParameter("@AcceptMan", "%"+this.CurrUser.UserId+"%")); } 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(); } #region 行点击事件 protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string id = e.RowID; if (e.CommandName.Equals("AttachUrl")) { string menuId = Const.ProjectControlPointMenuId; PageContext.RegisterStartupScript(WindowAtt.GetShowReference( String.Format("../AttachFile/Fileuploader.aspx?type=-1&source=1&toKeyId={0}&path=FileUpload/BreakdownProject&menuId={1}", id, menuId))); } else if (e.CommandName == "Print") { Print(id); } } #endregion 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(Window1.GetShowReference(String.Format("../Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath))); } } #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == "0") { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectControlPointMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnAdd)) { // this.btnNew.Hidden = false; } } } #endregion protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { InitTreeMenu(); } protected void RadioList2_SelectedIndexChanged(object sender, EventArgs e) { BindGrid(); } protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../DocManage/DocManageView.aspx?DocId={0}", Grid1.SelectedRowID, "查看 - "))); } #region 右键菜单事件 protected void btnMenuView_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../DocManage/DocManageView.aspx?DocId={0}", Grid1.SelectedRowID, "查看 - "))); } #endregion } }