private void GetClassTypes() { string ids = XYECOM.Core.XYRequest.GetQueryString("strID"); string Mode = XYECOM.Core.XYRequest.GetQueryString("Mode").Trim(); string moduleName = XYECOM.Core.XYRequest.GetQueryString("module"); string customParams = XYECOM.Core.XYRequest.GetQueryString("Params"); string str = ""; List<XYECOM.Model.XYClassInfo> classlist = null; if ("" == Mode)//获取列表 { Int64 tmpID = XYECOM.Core.MyConvert.GetInt64(ids); if (customParams != "") { classlist = XYECOM.Business.XYClass.GetSubItems(moduleName, tmpID, customParams); } else { classlist = XYECOM.Business.XYClass.GetSubItems(moduleName, tmpID); } if (null != classlist) { foreach (XYECOM.Model.XYClassInfo info in classlist) { str += "<Item><ID>" + info.ClassId.ToString() + "</ID><Name>" + Core.Utils.JSEscape(info.ClassName) + "</Name><HasSub>" + info.HasSub.ToString().ToLower() + "</HasSub></Item>"; } } } else if ("GetInfo" == Mode && "" != ids)//获取单条记录 { Int64 tmpID = XYECOM.Core.MyConvert.GetInt64(ids); XYECOM.Model.XYClassInfo info = new XYECOM.Model.XYClassInfo(); classlist = XYECOM.Business.XYClass.GetParentClassInfos(moduleName, tmpID); if (null != classlist) { string fullids = "", fullNames = ""; bool tmpok = true; foreach (XYECOM.Model.XYClassInfo sinfo in classlist) { if (tmpok) { info = sinfo; tmpok = false; } else { if ("" != fullids) fullids = "," + fullids; if ("" != fullNames) fullNames = "," + fullNames; fullids = sinfo.ClassId + fullids; fullNames = sinfo.ClassName + fullNames; } } str += "<ParentID>" + info.ParentId + "</ParentID><Name>" + Core.Utils.JSEscape(info.ClassName) + "</Name><HasSub>" + info.HasSub.ToString().ToLower() + "</HasSub><FullID>" + Core.Utils.JSEscape(fullids) + "</FullID><FullName>" + Core.Utils.JSEscape(fullNames) + "</FullName>"; } } else if ("GetInfos" == Mode && "" != ids)//获取多条记录 { classlist = XYECOM.Business.XYClass.GetSubItems(moduleName, ids); if (null != classlist) { foreach (XYECOM.Model.XYClassInfo info in classlist) { str += "<Item><ID>" + info.ClassId.ToString() + "</ID><Name>" + Core.Utils.JSEscape(info.ClassName) + "</Name><HasSub>" + info.HasSub.ToString().ToLower() + "</HasSub></Item>"; } } } if ("" != str) ResponseXML(Result.Success, "", str); else ResponseXML(Result.Failed, "暂无数据!"); }
/// <summary> /// ��������Ϣ���� /// </summary> /// <param name="tableInfo"></param> /// <param name="parentID"></param> /// <param name="moduleName"></param> /// <returns></returns> public List<Model.XYClassInfo> GetItems(Model.XYClassTableInfo tableInfo, long parentID, string moduleName) { string cmdText = "Select " + tableInfo.IdFieldName + "," + tableInfo.NameFieldName + "," + "(select count(" + tableInfo.IdFieldName + ") from " + tableInfo.TableName + " t2 where t2." + tableInfo.ParentIdFieldName + " = t1." + tableInfo.IdFieldName + ") as subids" + " From " + tableInfo.TableName + " t1 " + " Where " + tableInfo.ParentIdFieldName + " = " + parentID + " and " + tableInfo.ModuleFieldName + "='" + moduleName + "'" + " order by orderid"; List<Model.XYClassInfo> infos = new List<XYECOM.Model.XYClassInfo>(); using (SqlDataReader reader = Core.Data.SqlHelper.ExecuteReader(cmdText)) { while (reader.Read()) { Model.XYClassInfo info = new XYECOM.Model.XYClassInfo(); info.ClassId = Convert.ToInt64(reader[0]); info.ClassName = reader.GetString(1); info.HasSub = Convert.ToInt64(reader[2]) > 0; infos.Add(info); } } return infos; }
/// <summary> /// ��ȡ������Ϣ /// </summary> /// <param name="tableInfo">�������Ϣ</param> /// <param name="Id">����Id</param> /// <param name="moduleName">ģ������</param> /// <returns></returns> public Model.XYClassInfo GetItem(Model.XYClassTableInfo tableInfo, long Id, string moduleName) { string cmdText = "Select " + tableInfo.IdFieldName + "," + tableInfo.NameFieldName + "," + tableInfo.ParentIdFieldName + ", " + "(select count(" + tableInfo.IdFieldName + ") from " + tableInfo.TableName + " t2 where t2." + tableInfo.ParentIdFieldName + " = t1." + tableInfo.IdFieldName + ") as subids" + " From " + tableInfo.TableName + " t1 " + " Where " + tableInfo.IdFieldName + " = " + Id + " and " + tableInfo.ModuleFieldName + "='" + moduleName + "'" + " order by orderid"; Model.XYClassInfo info = null; using (SqlDataReader reader = Core.Data.SqlHelper.ExecuteReader(cmdText)) { if (reader.Read()) { info = new XYECOM.Model.XYClassInfo(); info.ClassId = Id; info.ClassName = reader.GetString(1); info.ParentId = XYECOM.Core.MyConvert.GetInt64(reader[2].ToString()); info.HasSub = XYECOM.Core.MyConvert.GetInt32(reader[3].ToString()) > 0; } } return info; }
/// <summary> /// ��ȡ������Ϣ /// </summary> /// <param name="tableInfo">�������Ϣ</param> /// <param name="className">��������</param> /// <returns></returns> public Model.XYClassInfo GetItem(Model.XYClassTableInfo tableInfo, string className) { string cmdText = "Select " + tableInfo.IdFieldName + "," + tableInfo.NameFieldName + "," + tableInfo.ParentIdFieldName + " " + " From " + tableInfo.TableName + " Where " + tableInfo.NameFieldName + " = '" + className + "'" + " order by orderid"; Model.XYClassInfo info = null; using (SqlDataReader reader = Core.Data.SqlHelper.ExecuteReader(cmdText)) { if (reader.Read()) { info = new XYECOM.Model.XYClassInfo(); info.ClassId = XYECOM.Core.MyConvert.GetInt64(reader[0].ToString()); info.ClassName = reader.GetString(1); info.ParentId = XYECOM.Core.MyConvert.GetInt64(reader[2].ToString()); } } return info; }
/// <summary> /// �Զ��������ȡ /// </summary> /// <param name="tableInfo"></param> /// <param name="parentID"></param> /// <param name="customParams"></param> /// <returns></returns> public List<Model.XYClassInfo> GetCustomParamsItems(Model.XYClassTableInfo tableInfo, long parentID, string customParams) { string strparams = GetParamsSql(tableInfo.TableName, customParams); string cmdText = "Select " + tableInfo.IdFieldName + "," + tableInfo.NameFieldName + "," + "(select count(" + tableInfo.IdFieldName + ") from " + tableInfo.TableName + " t2 where t2." + tableInfo.ParentIdFieldName + " = t1." + tableInfo.IdFieldName + ") as subids" + " From " + tableInfo.TableName + " t1 " + " Where (" + (parentID == 0 ? (tableInfo.ParentIdFieldName + " is null" + " or " + tableInfo.ParentIdFieldName + "=0 ") : (tableInfo.ParentIdFieldName + " = " + parentID)) + ")" + strparams + " order by orderid"; List<Model.XYClassInfo> infos = new List<XYECOM.Model.XYClassInfo>(); using (SqlDataReader reader = Core.Data.SqlHelper.ExecuteReader(cmdText)) { while (reader.Read()) { Model.XYClassInfo info = new XYECOM.Model.XYClassInfo(); info.ClassId = Convert.ToInt64(reader[0]); info.ClassName = reader.GetString(1); info.HasSub = Core.MyConvert.GetInt32(reader[2].ToString()) > 0; infos.Add(info); } } return infos; }