using System; using System.Data; using System.Linq; using System.Web.UI.WebControls; using SuperMap.RealEstate.CoreFrameWork; using SuperMap.RealEstate.CoreFrameWork.Dictionary.Business; using SuperMap.RealEstate.Enums; using SuperMap.RealEstate.Web.Utility; using SuperMap.RealEstate.Web.UI.WebControls; using SuperMap.RealEstate.WorkFlow; using Support = SuperMap.RealEstate.WorkFlow.Support.Business; using Instance = SuperMap.RealEstate.WorkFlow.Instance.Business; using HZQR.Common; namespace SuperMap.RealEstate.Finance.Leave { public partial class DefaultPage : SuperMap.RealEstate.Web.UI.PageModule { #region 方法 -> 页面加载事件 protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; BindDropDownList_SERVERPART(); #region 业务类型下拉列表 DataSet _DataSet = new DataSet(); if (Request["DataType"] == "List" && !string.IsNullOrEmpty(Request["Operation_Type"])) { Support.ProDefType _ProDefType = new Support.ProDefType(Transaction); //获取所有的分类节点 DataTable _DataTableType = _ProDefType.FillDataTable("order by ProDefType_PID,ProDefType_Index,ProDefType_ID"); //按照权限来过滤节点 string _SQLStr = @"Select A.* From V_ListAccept A,PlatForm_Dictionary.V_FieldEnum B,PlatForm_Dictionary.T_FieldEnum C Where A.User_ID = " + PassportInfo.ID + " And B.FieldExplain_Field = 'OPERATION_TYPE' And C.FieldEnum_Value = '" + Request["Operation_Type"].ToDecrypt() + "' And A.Operation_Type = B.FieldEnum_Value And B.FieldEnum_Pid = C.FieldEnum_ID"; DataTable _DataTableUser = _ProDefType.ExecuteDataTable(_SQLStr); _DataSet.Tables.Add(_DataTableType.Copy()); _DataSet.Tables.Add(_DataTableUser.Copy()); _DataSet.AcceptChanges(); } else { if (!string.IsNullOrEmpty(Request["Operation_Type"])) { _DataSet = SupportHelper.GetAcceptDataSet(PassportInfo.ID.ToString(), Request["Operation_Type"].ToDecrypt(), Transaction); } else { _DataSet = SupportHelper.GetAcceptDataSet(PassportInfo.ID.ToString(), "-1", this.Transaction); } } #endregion //绑定业务流程树 if (_DataSet.Tables[1].Rows.Count == 1) { LayoutButtonAccept.Visible = false; CallBackButtonAccept.Attributes["key"] = _DataSet.Tables[1].Rows[0]["ProDef_ID"].ToEncrypt() + "&Module_ID=" + this.ModuleInfo.ID.Value.ToEncrypt() + NewMethod(_DataSet.Tables[1].Rows[0]["Enabled_Division"].ToString()); CallBackButtonAccept.OnClientClick = "return WorkFlowPlatform_Accept(event,this);"; } else { LayoutButtonAccept.Visible = _DataSet.Tables[1].Rows.Count > 0; CallBackButtonAccept.Visible = false; TreeViewBinding("-1", MyTreeView.Nodes, _DataSet); } //绑定业务流程树 BindGridVew(); //设置回车焦点按钮 SetControlClientAction(ButtonSearch); } /// /// 返回业务流程服务区编码 /// /// /// private string NewMethod(string Enabled_Division) { if (Enabled_Division == "1") { return "&Enabled_Division=" + Division_Code.ClientID; } return ""; } #region 设置页面模块guid protected override void OnInit(EventArgs e) { if (Request["Module_ID"] != null) { this.AddModule_Guid(Guid.Empty.ToString()); } this.AddModule_Guid("45ca39de-5de5-465f-9718-969e16023711"); base.OnInit(e); } #endregion #region 绑定服务区下拉框 public void BindDropDownList_SERVERPART() { //绑定业务所在区域 Division_Code.Items.Clear(); Division_Code.Items.Add(new ListItemEx("全部", "-1")); Division_Code.Items.Add(new ListItemEx("非区域流程", "0") { Level = 1 }); DictionaryHelper.BindingDivisionCode(PassportInfo, Division_Code.Items, this.Transaction); } #endregion #region 绑定业务流程树 string _NavigateElement = " {1}"; private void TreeViewBinding(string pid, TreeNodeCollection Nodes, DataSet dataSet) { var pairCollection1 = from m in dataSet.Tables[0].Select("ProDefType_PID=" + pid) select new TreeNode() { Text = " " + m["ProDefType_Name"].ToString(), Value = m["ProDefType_ID"].ToString(), NavigateUrl = "javascript:void(0);", ImageUrl = TreeNodeImageUrl.BusinessSystem }; foreach (var pair1 in pairCollection1) { TreeViewBinding(pair1.Value, pair1.ChildNodes, dataSet); var pairCollection2 = from m in dataSet.Tables[1].Select("ProDefType_ID=" + pair1.Value) select new TreeNode() { Text = string.Format(_NavigateElement, m["ProDef_ID"].ToEncrypt() + "&Module_ID=" + this.ModuleInfo.ID.Value.ToEncrypt() + NewMethod(m["Enabled_Division"].ToString()), m["ProDef_Name"].ToString()), Value = m["ProDef_ID"].ToString(), NavigateUrl = "javascript:void(0);", ImageUrl = TreeNodeImageUrl.Module }; foreach (var pair2 in pairCollection2) { pair1.ChildNodes.Add(pair2); } if (pair1.ChildNodes.Count > 0) { Nodes.Add(pair1); } } } #endregion #endregion #region 方法 -> 加载列表数据 private void BindGridVew() { //将请假类型转换为文字显示 GridViewEx1.SelectingWithInit(ObjectDataSource1, GridPageEx1, DictionaryHelper.GetDictionary(Transaction, "LEAVE_TYPE")); } #endregion #region 方法 -> 查询 protected void ButtonSearch_CallBackClick(object sender, ClientSetEventArgs e) { GridViewEx1.Selecting(ObjectDataSource1, GridPageEx1); //设置UI变化 e.SetValue(GridViewEx1); e.SetValue(GridPageEx1); } #endregion #region 方法 -> 翻页事件 protected void GridPageEx1_CallBackPageChanged(object src, ClientSetEventArgs e) { GridViewEx1.Pagging(ObjectDataSource1, GridPageEx1); //设置UI变化 e.SetValue(GridViewEx1); } #endregion #region 方法 -> 查询SQL设置 public string sqlWhere = string.Empty; protected void GridViewEx1_SelectMethodParameters(object sender, SelectMethodParametersArgs e) { //搜索选项的搜索条件过滤 if (!string.IsNullOrEmpty(TextBox_Search.Text)) e.AddOrParams(GridViewSearch1, TextBox_Search.Text); //且搜索条件 e.AddAndParams("USER_ID", PassportInfo.ID); e.AddOrderByParams(LayoutButton_OrderBy, CheckBoxExOrderBy.Checked); } #endregion #region 方法 -> 行绑定事件 protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string _ProInst_ID = GridViewEx1.DataKeys[e.Row.RowIndex]["ProInst_ID"].ToEncrypt(); string _NowActInst_ID = GridViewEx1.DataKeys[e.Row.RowIndex]["NowActInst_ID"].ToEncrypt(); string _LEAVE_STARTDATE = GridViewEx1.DataKeys[e.Row.RowIndex]["LEAVE_STARTDATE"].ToString(); //请假天数 string _DURATION_DAYS = GridViewEx1.DataKeys[e.Row.RowIndex]["DURATION_DAYS"].ToString(); //获取请假结束时间 if (GridViewEx1.DataKeys[e.Row.RowIndex]["LEAVE_ENDDATE"].ToString() != "") { string _LEAVE_ENDDATE = Convert.ToDateTime(GridViewEx1.DataKeys[e.Row.RowIndex]["LEAVE_ENDDATE"]).ToString("yyyy-MM-dd"); //判断起始时间和请假结束时间是否有值 if (!string.IsNullOrWhiteSpace(e.Row.Cells[5].Text) && !string.IsNullOrWhiteSpace(_LEAVE_ENDDATE)) { //获取时间间隔 TimeSpan _TimeSpan = (_LEAVE_ENDDATE.TryParseToDateTime() - e.Row.Cells[5].Text.TryParseToDateTime()).Value; if (_TimeSpan.TotalDays <= 1) { //设置请假天数为1 _DURATION_DAYS = "1"; } else { _DURATION_DAYS = _TimeSpan.TotalDays.ToString("0"); } //请假时间 e.Row.Cells[5].Text = e.Row.Cells[5].Text + "-" + _LEAVE_ENDDATE + "(" + _DURATION_DAYS + "天)"; } else { e.Row.Cells[5].Text = "请假结束时间未知"; } if (!string.IsNullOrEmpty(e.Row.Cells[4].Text) && e.Row.Cells[4].Text.Length > 20) { e.Row.Cells[4].ToolTip = e.Row.Cells[4].Text; e.Row.Cells[4].Text = e.Row.Cells[4].Text.Substring(0, 20) + "..."; e.Row.Cells[4].Width = 100; } if (!string.IsNullOrWhiteSpace(TextBox_Search.Text.Trim())) { //所在部门 e.Row.Cells[1].Text = e.Row.Cells[1].Text.Replace(TextBox_Search.Text.Trim(), "" + TextBox_Search.Text.Trim() + ""); //请假人员 e.Row.Cells[2].Text = e.Row.Cells[2].Text.Replace(TextBox_Search.Text.Trim(), "" + TextBox_Search.Text.Trim() + ""); //请假事由 e.Row.Cells[3].Text = e.Row.Cells[3].Text.Replace(TextBox_Search.Text.Trim(), "" + TextBox_Search.Text.Trim() + ""); //请假类型 e.Row.Cells[4].Text = e.Row.Cells[4].Text.Replace(TextBox_Search.Text.Trim(), "" + TextBox_Search.Text.Trim() + ""); } } //行点击事件 e.Row.Attributes.Add("onclick", "return WorkFlowPlatform_Transact(event,\"?NowActInst_ID=" + _NowActInst_ID + "&Module_ID=" + Request["Module_ID"] + "&ProInst_ID=" + _ProInst_ID + "\",false);"); } } #endregion } }