/// <summary> /// 获取节点绑定人员信息列表 /// </summary> /// <returns></returns> public string Dot2DotTreeDeptEmpModel_GetNodeEmps() { JsonResultInnerData jr = new JsonResultInnerData(); DataTable dt = null; string nid = this.GetRequestVal("nodeid"); int pagesize = int.Parse(this.GetRequestVal("pagesize")); int pageidx = int.Parse(this.GetRequestVal("pageidx")); string sql = "SELECT pe.No,pe.Name,pd.No DeptNo,pd.Name DeptName FROM WF_NodeEmp wne " + " INNER JOIN Port_Emp pe ON pe.No = wne.FK_Emp " + " LEFT JOIN Port_Dept pd ON pd.No = pe.FK_Dept " + "WHERE wne.FK_Node = " + nid + " ORDER BY pd.Idx, pe.Name"; dt = DBAccess.RunSQLReturnTable(sql); //, pagesize, pageidx, "No", "Name", "ASC" dt.Columns.Add("Code", typeof(string)); dt.Columns.Add("Checked", typeof(bool)); foreach (DataRow row in dt.Rows) { if ((Glo.Plant == BP.WF.Plant.JFlow) && (DBAccess.AppCenterDBType == DBType.Oracle)) { row["Code"] = BP.Tools.chs2py.ConvertStr2Code(row["NAME"] as string); } else { row["Code"] = BP.Tools.chs2py.ConvertStr2Code(row["Name"] as string); } row["Checked"] = true; } //对Oracle数据库做兼容性处理 if (DBAccess.AppCenterDBType == DBType.Oracle) { foreach (DataColumn col in dt.Columns) { switch (col.ColumnName) { case "NO": col.ColumnName = "No"; break; case "NAME": col.ColumnName = "Name"; break; case "DEPTNO": col.ColumnName = "DeptNo"; break; case "DEPTNAME": col.ColumnName = "DeptName"; break; } } } jr.InnerData = dt; return(Newtonsoft.Json.JsonConvert.SerializeObject(jr)); }
/// <summary> /// 获取节点绑定人员信息列表 /// </summary> /// <returns></returns> public string Dot2DotTreeDeptModel_GetNodeDepts() { JsonResultInnerData jr = new JsonResultInnerData(); DataTable dt = null; string nid = this.GetRequestVal("nodeid"); string sql = "SELECT pd.No,pd.Name,pd1.No DeptNo,pd1.Name DeptName FROM WF_NodeDept wnd " + " INNER JOIN Port_Dept pd ON pd.No = wnd.FK_Dept " + " LEFT JOIN Port_Dept pd1 ON pd1.No = pd.ParentNo " + "WHERE wnd.FK_Node = " + nid + " ORDER BY pd1.Idx, pd.Name"; dt = DBAccess.RunSQLReturnTable(sql); //, pagesize, pageidx, "No", "Name", "ASC" dt.Columns.Add("Code", typeof(string)); dt.Columns.Add("Checked", typeof(bool)); foreach (DataRow row in dt.Rows) { row["Code"] = BP.Tools.chs2py.ConvertStr2Code(row["Name"] as string); row["Checked"] = true; } //对Oracle数据库做兼容性处理 if (DBAccess.AppCenterDBType == DBType.Oracle) { foreach (DataColumn col in dt.Columns) { switch (col.ColumnName) { case "NO": col.ColumnName = "No"; break; case "NAME": col.ColumnName = "Name"; break; case "DEPTNO": col.ColumnName = "DeptNo"; break; case "DEPTNAME": col.ColumnName = "DeptName"; break; } } } jr.InnerData = dt; string re = BP.Tools.Json.ToJson(jr); if (Glo.Plant == BP.WF.Plant.JFlow) { re = re.Replace("\"NO\"", "\"No\"").Replace("\"NAME\"", "\"Name\"").Replace("\"DEPTNO\"", "\"DeptNo\"").Replace("\"DEPTNAME\"", "\"DeptName\""); } return(re); }
/// <summary> /// 获取节点绑定人员信息列表 /// </summary> /// <returns></returns> public string Dot2DotStationModel_GetNodeStations() { JsonResultInnerData jr = new JsonResultInnerData(); DataTable dt = null; string nid = this.GetRequestVal("nodeid"); int pagesize = int.Parse(this.GetRequestVal("pagesize")); int pageidx = int.Parse(this.GetRequestVal("pageidx")); string st = this.GetRequestVal("stype"); string sql = string.Empty; string sortField = CheckStationTypeIdxExists() ? "Idx" : "No"; if (st == "UNIT") { sql = "SELECT ps.No,ps.Name,pd.No UnitNo,pd.Name UnitName FROM WF_NodeStation wns " + " INNER JOIN Port_Station ps ON ps.No = wns.FK_Station " + " INNER JOIN Port_Dept pd ON pd.No = ps.FK_Unit " + "WHERE wns.FK_Node = " + nid + " ORDER BY ps.Name ASC"; } else { sql = "SELECT ps.No,ps.Name,pst.No UnitNo,pst.Name UnitName FROM WF_NodeStation wns " + " INNER JOIN Port_Station ps ON ps.No = wns.FK_Station " + " INNER JOIN Port_StationType pst ON pst.No = ps.FK_StationType " + "WHERE wns.FK_Node = " + nid + " ORDER BY pst." + sortField + " ASC,ps.Name ASC"; } dt = DBAccess.RunSQLReturnTable(sql); //, pagesize, pageidx, "No", "Name", "ASC" dt.Columns.Add("Code", typeof(string)); dt.Columns.Add("Checked", typeof(bool)); foreach (DataRow row in dt.Rows) { row["Code"] = BP.Tools.chs2py.ConvertStr2Code(row["Name"] as string); row["Checked"] = true; } //对Oracle数据库做兼容性处理 if (DBAccess.AppCenterDBType == DBType.Oracle) { foreach (DataColumn col in dt.Columns) { switch (col.ColumnName) { case "NO": col.ColumnName = "No"; break; case "NAME": col.ColumnName = "Name"; break; case "UNITNO": col.ColumnName = "DeptNo"; break; case "UNITNAME": col.ColumnName = "DeptName"; break; } } } jr.InnerData = dt; jr.Msg = ""; string re = Newtonsoft.Json.JsonConvert.SerializeObject(jr); if (Glo.Plant == BP.WF.Plant.JFlow) { re = re.Replace("\"NO\"", "\"No\"").Replace("\"NAME\"", "\"Name\"").Replace("\"UNITNO\"", "\"UnitNo\"").Replace("\"UNITNAME\"", "\"UnitName\""); } return(Newtonsoft.Json.JsonConvert.SerializeObject(re)); }
/// <summary> /// 获取部门树根结点 /// </summary> /// <returns></returns> public string Dot2DotStationModel_GetStructureTreeRoot() { JsonResultInnerData jr = new JsonResultInnerData(); EasyuiTreeNode node, subnode; List <EasyuiTreeNode> d = new List <EasyuiTreeNode>(); string parentrootid = this.GetRequestVal("parentrootid"); string sql = null; DataTable dt = null; if (string.IsNullOrWhiteSpace(parentrootid)) { throw new Exception("参数parentrootid不能为空"); } CheckStationTypeIdxExists(); bool isUnitModel = DBAccess.IsExitsTableCol("Port_Dept", "IsUnit"); if (isUnitModel) { bool isValid = DBAccess.IsExitsTableCol("Port_Station", "FK_Unit"); if (!isValid) { isUnitModel = false; } } if (isUnitModel) { sql = string.Format("SELECT No,Name,ParentNo FROM Port_Dept WHERE IsUnit = 1 AND ParentNo = '{0}'", parentrootid); dt = DBAccess.RunSQLReturnTable(sql); if (dt.Rows.Count == 0) { dt.Rows.Add("-1", "无单位数据", parentrootid); } node = new EasyuiTreeNode(); node.id = "UNITROOT_" + dt.Rows[0]["No"]; node.text = dt.Rows[0]["Name"] as string; node.iconCls = "icon-department"; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = dt.Rows[0]["No"] as string; node.attributes.Name = dt.Rows[0]["Name"] as string; node.attributes.ParentNo = parentrootid; node.attributes.TType = "UNITROOT"; node.state = "closed"; if (node.text != "无单位数据") { node.children = new List <EasyuiTreeNode>(); node.children.Add(new EasyuiTreeNode()); node.children[0].text = "loading..."; } d.Add(node); } else { sql = "SELECT No,Name FROM Port_StationType"; dt = DBAccess.RunSQLReturnTable(sql); node = new EasyuiTreeNode(); node.id = "STROOT_-1"; node.text = "岗位类型"; node.iconCls = "icon-department"; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = "-1"; node.attributes.Name = "岗位类型"; node.attributes.ParentNo = parentrootid; node.attributes.TType = "STROOT"; node.state = "closed"; if (dt.Rows.Count > 0) { node.children = new List <EasyuiTreeNode>(); node.children.Add(new EasyuiTreeNode()); node.children[0].text = "loading..."; } d.Add(node); } jr.InnerData = d; jr.Msg = isUnitModel.ToString().ToLower(); return(Newtonsoft.Json.JsonConvert.SerializeObject(jr)); }
/// <summary> /// 保存节点绑定人员信息 /// </summary> /// <returns></returns> public string Dot2DotTreeDeptEmpModel_SaveNodeEmps() { JsonResultInnerData jr = new JsonResultInnerData(); string nodeid = this.GetRequestVal("nodeid"); string data = this.GetRequestVal("data"); string partno = this.GetRequestVal("partno"); bool lastpart = false; int partidx = 0; int partcount = 0; int nid = 0; if (string.IsNullOrWhiteSpace(nodeid) || int.TryParse(nodeid, out nid) == false) { throw new Exception("参数nodeid不正确"); } if (string.IsNullOrWhiteSpace(data)) { data = ""; } BP.WF.Template.NodeEmps nemps = new BP.WF.Template.NodeEmps(); string[] empNos = data.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); //提交内容过长时,采用分段式提交 if (string.IsNullOrWhiteSpace(partno)) { nemps.Delete(BP.WF.Template.NodeEmpAttr.FK_Node, nid); } else { string[] parts = partno.Split("/".ToCharArray()); if (parts.Length != 2) { throw new Exception("参数partno不正确"); } partidx = int.Parse(parts[0]); partcount = int.Parse(parts[1]); empNos = data.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (partidx == 1) { nemps.Delete(BP.WF.Template.NodeEmpAttr.FK_Node, nid); } lastpart = partidx == partcount; } DataTable dtEmps = DBAccess.RunSQLReturnTable("SELECT No FROM Port_Emp"); BP.WF.Template.NodeEmp nemp = null; foreach (string empNo in empNos) { if (dtEmps.Select(string.Format("No='{0}'", empNo)).Length + dtEmps.Select(string.Format("NO='{0}'", empNo)).Length == 0) { continue; } nemp = new BP.WF.Template.NodeEmp(); nemp.FK_Node = nid; nemp.FK_Emp = empNo; nemp.Insert(); } if (string.IsNullOrWhiteSpace(partno)) { jr.Msg = "保存成功"; } else { jr.InnerData = new { lastpart, partidx, partcount }; if (lastpart) { jr.Msg = "保存成功"; } else { jr.Msg = string.Format("第{0}/{1}段保存成功", partidx, partcount); } } return(Newtonsoft.Json.JsonConvert.SerializeObject(jr)); }
/// <summary> /// 获取部门树根结点 /// </summary> /// <returns></returns> public string Dot2DotTreeDeptModel_GetStructureTreeRoot() { JsonResultInnerData jr = new JsonResultInnerData(); EasyuiTreeNode node = null; List <EasyuiTreeNode> d = new List <EasyuiTreeNode>(); string parentrootid = this.GetRequestVal("parentrootid"); string nodeid = this.GetRequestVal("nodeid"); if (string.IsNullOrWhiteSpace(parentrootid)) { throw new Exception("参数parentrootid不能为空"); } if (string.IsNullOrWhiteSpace(nodeid)) { throw new Exception("参数nodeid不能为空"); } if (BP.WF.Glo.OSModel == OSModel.OneOne) { BP.WF.Port.Dept dept = new BP.WF.Port.Dept(); if (dept.Retrieve(BP.WF.Port.DeptAttr.ParentNo, parentrootid) == 0) { dept.No = "-1"; dept.Name = "无部门"; dept.ParentNo = ""; } node = new EasyuiTreeNode(); node.id = "DEPT_" + dept.No; node.text = dept.Name; node.iconCls = "icon-department"; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = dept.No; node.attributes.Name = dept.Name; node.attributes.ParentNo = dept.ParentNo; node.@checked = new NodeDept().IsExit(NodeDeptAttr.FK_Node, int.Parse(nodeid), NodeDeptAttr.FK_Dept, dept.No); node.attributes.TType = "DEPT"; node.state = "closed"; node.children = new List <EasyuiTreeNode>(); node.children.Add(new EasyuiTreeNode()); node.children[0].text = "loading..."; d.Add(node); } else { BP.GPM.Dept dept = new BP.GPM.Dept(); if (dept.Retrieve(BP.GPM.DeptAttr.ParentNo, parentrootid) == 0) { dept.No = "-1"; dept.Name = "无部门"; dept.ParentNo = ""; } node = new EasyuiTreeNode(); node.id = "DEPT_" + dept.No; node.text = dept.Name; node.iconCls = "icon-department"; node.attributes = new EasyuiTreeNodeAttributes(); node.attributes.No = dept.No; node.attributes.Name = dept.Name; node.attributes.ParentNo = dept.ParentNo; node.@checked = new NodeDept().IsExit(NodeDeptAttr.FK_Node, int.Parse(nodeid), NodeDeptAttr.FK_Dept, dept.No); node.attributes.TType = "DEPT"; node.state = "closed"; node.children = new List <EasyuiTreeNode>(); node.children.Add(new EasyuiTreeNode()); node.children[0].text = "loading..."; d.Add(node); } jr.InnerData = d; return(Newtonsoft.Json.JsonConvert.SerializeObject(jr)); }