Example #1
0
        /// <summary>
        /// 获取有记录的所有类型
        /// </summary>
        /// <param name="sw"></param>
        /// <returns></returns>
        public static IEnumerable <T_SYS_DICTModel> getDict45(T_SYS_ORG_LINK_SW sw)
        {
            DataTable dt45 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW {
                DICTTYPEID = "45"
            });                                             //组织机构联系人类型
            DataTable dt = BaseDT.T_SYS_ORG_LINK.getDT(sw); //列表

            var result = new List <T_SYS_DICTModel>();

            for (int i = 0; i < dt45.Rows.Count; i++)
            {
                T_SYS_DICTModel m = new T_SYS_DICTModel();
                m.DICTTYPEID = dt45.Rows[i]["DICTTYPEID"].ToString();
                m.DICTID     = dt45.Rows[i]["DICTID"].ToString();
                m.DICTTYPEID = dt45.Rows[i]["DICTTYPEID"].ToString();
                m.DICTNAME   = dt45.Rows[i]["DICTNAME"].ToString();
                m.DICTVALUE  = dt45.Rows[i]["DICTVALUE"].ToString();
                m.ORDERBY    = dt45.Rows[i]["ORDERBY"].ToString();
                m.STANDBY1   = dt45.Rows[i]["STANDBY1"].ToString();
                m.STANDBY2   = dt45.Rows[i]["STANDBY2"].ToString();
                m.STANDBY3   = dt45.Rows[i]["STANDBY3"].ToString();
                m.STANDBY4   = dt45.Rows[i]["STANDBY4"].ToString();
                DataRow[] dr = dt.Select("ORGLINKTYPE='" + m.DICTVALUE + "'");
                //if(dr.Count()>0)不需要判断是否有记录,而是显示所有类别
                result.Add(m);
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// 获取记录
        /// </summary>
        /// <param name="sw"></param>
        /// <returns></returns>
        public static DataTable getDT(T_SYS_ORG_LINK_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" FROM      T_SYS_ORG_LINK");
            sb.AppendFormat(" WHERE   1=1");
            if (string.IsNullOrEmpty(sw.ORGLINK_ID) == false)
            {
                sb.AppendFormat(" AND ORGLINK_ID = '{0}'", ClsSql.EncodeSql(sw.ORGLINK_ID));
            }
            if (string.IsNullOrEmpty(sw.ORGNO) == false)
            {
                sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO));
            }
            if (string.IsNullOrEmpty(sw.ORGLINKTYPE) == false)
            {
                sb.AppendFormat(" AND ORGLINKTYPE = '{0}'", ClsSql.EncodeSql(sw.ORGLINKTYPE));
            }
            if (string.IsNullOrEmpty(sw.PHONE) == false)
            {
                if (sw.PHONE.Split(',').Length > 1)
                {
                    sb.AppendFormat(" AND PHONE in({0})", ClsSql.SwitchStrToSqlIn(sw.PHONE));
                }
                else
                {
                    sb.AppendFormat(" AND PHONE ='{0}'", ClsSql.EncodeSql(sw.PHONE));
                }
            }
            if (string.IsNullOrEmpty(sw.keys) == false)
            {
                sb.AppendFormat(" AND (NAME like '%{0}%' or USERJOB like '%{0}%' or PHONE like '%{0}%' or Tell like '%{0}%' or UNITNAME like '%{0}%')", ClsSql.EncodeSql(sw.keys));
            }
            if (!string.IsNullOrEmpty(sw.BYORGNO))
            {
                if (sw.BYORGNO.Substring(4, 11) == "00000000000")//获取所有市的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,4) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4)));
                }
                else if (sw.BYORGNO.Substring(6, 9) == "000000000")//获取所有县的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,6) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
                }
                else if (sw.BYORGNO.Substring(9, 6) == "000000")//获取所有乡镇的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
                }
                else
                {
                    sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
                }
            }
            string sql = "SELECT ORGLINK_ID, BYORGNO, ORGLINKTYPE,UNITNAME, NAME, USERJOB, PHONE, Tell, ORDERBY"
                         + sb.ToString()
                         + " order by BYORGNO,ORGLINKTYPE,ORDERBY";

            DataSet ds = DataBaseClass.FullDataSet(sql);

            return(ds.Tables[0]);
        }
Example #3
0
        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="sw"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static DataTable getDT(T_SYS_ORG_LINK_SW sw, out int total)
        {
            StringBuilder sb = new StringBuilder();


            sb.AppendFormat(" FROM      T_SYS_ORG_LINK");
            sb.AppendFormat(" WHERE   1=1");
            if (string.IsNullOrEmpty(sw.ORGLINK_ID) == false)
            {
                sb.AppendFormat(" AND ORGLINK_ID = '{0}'", ClsSql.EncodeSql(sw.ORGLINK_ID));
            }
            if (string.IsNullOrEmpty(sw.ORGNO) == false)
            {
                sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.ORGNO));
            }
            if (string.IsNullOrEmpty(sw.ORGLINKTYPE) == false)
            {
                sb.AppendFormat(" AND ORGLINKTYPE = '{0}'", ClsSql.EncodeSql(sw.ORGLINKTYPE));
            }
            if (string.IsNullOrEmpty(sw.keys) == false)
            {
                sb.AppendFormat(" AND (NAME like '%{0}%' or USERJOB like '%{0}%' or PHONE like '%{0}%' or Tell like '%{0}%')", ClsSql.EncodeSql(sw.keys));
            }
            if (!string.IsNullOrEmpty(sw.BYORGNO))
            {
                if (sw.BYORGNO.Substring(4, 11) == "00000000000")//获取所有市的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,4) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4)));
                }
                else if (sw.BYORGNO.Substring(6, 9) == "000000000")//获取所有县的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,6) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6)));
                }
                else if (sw.BYORGNO.Substring(9, 6) == "000000")//获取所有乡镇的
                {
                    sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9)));
                }
                else
                {
                    sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
                }
            }
            string sql = "SELECT ORGLINK_ID, BYORGNO, ORGLINKTYPE, UNITNAME,NAME, USERJOB, PHONE, Tell, ORDERBY"
                         + sb.ToString()
                         + " order by BYORGNO,ORGLINKTYPE,ORDERBY";

            string sqlC = "select count(1) " + sb.ToString();

            total      = int.Parse(DataBaseClass.ReturnSqlField(sqlC));
            sw.curPage = PagerCls.getCurPage(new PagerSW {
                curPage = sw.curPage, pageSize = sw.pageSize, rowCount = total
            });
            DataSet ds = DataBaseClass.FullDataSet(sql, (sw.curPage - 1) * sw.pageSize, sw.pageSize, "a");

            return(ds.Tables[0]);
        }
Example #4
0
        /// <summary>
        /// 判断记录是否存在
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>true存在 false不存在</returns>
        public static bool isExists(T_SYS_ORG_LINK_SW sw)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("select 1 from T_SYS_ORG_LINK where 1=1");
            if (string.IsNullOrEmpty(sw.ORGLINK_ID) == false)
            {
                sb.AppendFormat(" AND ORGLINK_ID= '{0}'", ClsSql.EncodeSql(sw.ORGLINK_ID));
            }
            if (string.IsNullOrEmpty(sw.BYORGNO) == false)
            {
                sb.AppendFormat(" AND BYORGNO= '{0}'", ClsSql.EncodeSql(sw.BYORGNO));
            }
            if (string.IsNullOrEmpty(sw.PHONE) == false)
            {
                sb.AppendFormat(" AND PHONE= '{0}'", ClsSql.EncodeSql(sw.PHONE));
            }
            if (string.IsNullOrEmpty(sw.ORDERBY) == false)
            {
                sb.AppendFormat(" AND ORDERBY= '{0}'", ClsSql.EncodeSql(sw.ORDERBY));
            }
            return(DataBaseClass.JudgeRecordExists(sb.ToString()));
        }
Example #5
0
        /// <summary>
        /// 根据查询条件获取某一条用户信息记录,用于修改、删除、用户登录验证
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static T_SYS_ORG_LINK_Model getModel(T_SYS_ORG_LINK_SW sw)
        {
            var result = new List <T_SYS_ORG_LINK_Model>();

            DataTable dt = BaseDT.T_SYS_ORG_LINK.getDT(sw);//列表

            DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW {
                SYSFLAG = ConfigCls.getSystemFlag()
            });                                                                                               //获取单位
            DataTable dt45 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW {
                DICTTYPEID = "45"
            });                                                                              //组织机构联系人类型
            T_SYS_ORG_LINK_Model m = new T_SYS_ORG_LINK_Model();

            if (dt.Rows.Count > 0)
            {
                int i = 0;
                m.ORGLINK_ID      = dt.Rows[i]["ORGLINK_ID"].ToString();
                m.BYORGNO         = dt.Rows[i]["BYORGNO"].ToString();
                m.ORGLINKTYPE     = dt.Rows[i]["ORGLINKTYPE"].ToString();
                m.ORGLINKTYPEName = BaseDT.T_SYS_DICT.getName(dt45, m.ORGLINKTYPE);
                m.UNITNAME        = dt.Rows[i]["UNITNAME"].ToString();
                m.NAME            = dt.Rows[i]["NAME"].ToString();
                m.USERJOB         = dt.Rows[i]["USERJOB"].ToString();
                m.PHONE           = dt.Rows[i]["PHONE"].ToString();
                m.Tell            = dt.Rows[i]["Tell"].ToString();
                m.ORDERBY         = dt.Rows[i]["ORDERBY"].ToString();
                m.ORGName         = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO);
            }
            dt.Clear();
            dt.Dispose();
            dtORG.Clear();
            dtORG.Dispose();
            dt45.Clear();
            dt45.Dispose();
            return(m);
        }