/// <summary> /// 获取列表 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <DC_REPOSITORY_Model> getModelList(DC_REPOSITORY_SW sw) { var result = new List <DC_REPOSITORY_Model>(); DataTable dt = BaseDT.DC_REPOSITORY.getDT(sw);//列表 DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); for (int i = 0; i < dt.Rows.Count; i++) { DC_REPOSITORY_Model m = new DC_REPOSITORY_Model(); m.DCREPOSITORYID = dt.Rows[i]["DCREPOSITORYID"].ToString(); m.NAME = dt.Rows[i]["NAME"].ToString(); m.ADDRESS = dt.Rows[i]["ADDRESS"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ORGName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); //string orgname = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.COMNAME = "[" + m.ORGName + "]" + m.NAME + ""; //m.COMNAME = "[" + orgname + "]" + m.NAME + ""; m.RESPONSIBLEMAN = dt.Rows[i]["RESPONSIBLEMAN"].ToString(); m.LINKWAY = dt.Rows[i]["LINKWAY"].ToString(); m.REPTYPEID = dt.Rows[i]["REPTYPEID"].ToString(); m.JD = dt.Rows[i]["JD"].ToString(); m.WD = dt.Rows[i]["WD"].ToString(); result.Add(m); } dt.Clear(); dt.Dispose(); dtORG.Clear(); dtORG.Dispose(); return(result); }
/// <summary> /// 单条记录 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static DC_REPOSITORY_Model getModel(DC_REPOSITORY_SW sw) { DataTable dt = BaseDT.DC_REPOSITORY.getDT(sw);//列表 DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); DC_REPOSITORY_Model m = new DC_REPOSITORY_Model(); if (dt.Rows.Count > 0) { int i = 0; m.DCREPOSITORYID = dt.Rows[i]["DCREPOSITORYID"].ToString(); m.NAME = dt.Rows[i]["NAME"].ToString(); m.ADDRESS = dt.Rows[i]["ADDRESS"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ORGName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.RESPONSIBLEMAN = dt.Rows[i]["RESPONSIBLEMAN"].ToString(); m.LINKWAY = dt.Rows[i]["LINKWAY"].ToString(); m.REPTYPEID = dt.Rows[i]["REPTYPEID"].ToString(); m.JD = dt.Rows[i]["JD"].ToString(); m.WD = dt.Rows[i]["WD"].ToString(); } dt.Clear(); dt.Dispose(); return(m); }
/// <summary> /// 获取数据 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static DataTable getDT(DC_REPOSITORY_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" from DC_REPOSITORY a "); sb.AppendFormat(" where 1=1 "); if (string.IsNullOrEmpty(sw.DCREPOSITORYID) == false) { sb.AppendFormat(" and DCREPOSITORYID = '{0}'", ClsSql.EncodeSql(sw.DCREPOSITORYID)); } if (string.IsNullOrEmpty(sw.REPTYPEID) == false) { sb.AppendFormat("and REPTYPEID = '{0}'", ClsSql.EncodeSql(sw.REPTYPEID)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat("and NAME = '{0}'", ClsSql.EncodeSql(sw.NAME)); } if (string.IsNullOrEmpty(sw.ADDRESS) == false) { sb.AppendFormat("and ADDRESS = '{0}'", ClsSql.EncodeSql(sw.ADDRESS)); } 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 if (sw.BYORGNO.Substring(12, 3) == "000") //获取说有村的 { sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,12) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 12))); } else { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } } if (string.IsNullOrEmpty(sw.RESPONSIBLEMAN) == false) { sb.AppendFormat("and RESPONSIBLEMAN = '{0}'", ClsSql.EncodeSql(sw.RESPONSIBLEMAN)); } if (string.IsNullOrEmpty(sw.LINKWAY) == false) { sb.AppendFormat("and LINKWAY = '{0}'", ClsSql.EncodeSql(sw.LINKWAY)); } string sql = ("select DCREPOSITORYID,REPTYPEID,NAME,ADDRESS,BYORGNO,RESPONSIBLEMAN,LINKWAY,JD,WD") + sb.ToString() + ("order by BYORGNO,DCREPOSITORYID desc"); DataSet ds = DataBaseClass.FullDataSet(sql); return(ds.Tables[0]); }
/// <summary> /// 获取仓库下拉框 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static string getSelectOption(DC_REPOSITORY_SW sw) { StringBuilder sb = new StringBuilder(); DataTable dt = BaseDT.DC_REPOSITORY.getDT(sw); if (sw.Other == "1") { sb.AppendFormat("<option value=\"\">{0}</option>", "其他"); } sb.AppendFormat("<option value=\"办公室\">{0}</option>", "办公室"); for (int i = 0; i < dt.Rows.Count; i++) { string name = dt.Rows[i]["NAME"].ToString(); string dcrepid = dt.Rows[i]["DCREPOSITORYID"].ToString(); sb.AppendFormat("<option value=\"{0}\">{1}</option>", dcrepid, name); } dt.Clear(); dt.Dispose(); return(sb.ToString()); }
/// <summary> /// 统计当前用户下装备的记录数量 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static string getNum(DC_REPOSITORY_SW sw) { string total = ""; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" from DC_REPOSITORY a "); sb.AppendFormat("where 1 = 1 "); 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" && sw.BYORGNO.Substring(4, 11) != "00000000000") //获取所有县的 { sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,6) = '{0}' or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 6))); } else { sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,9) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 9))); } string sqlC = "select count(1) " + sb.ToString(); total = (DataBaseClass.ReturnSqlField(sqlC)).ToString(); return(total); }
/// <summary> /// 获取分页 /// </summary> /// <param name="sw"></param> /// <param name="total"></param> /// <returns></returns> public static DataTable getDT(DC_REPOSITORY_SW sw, out int total) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" FROM DC_REPOSITORY"); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.REPTYPEID) == false) { sb.AppendFormat("and REPTYPEID = '{0}'", ClsSql.EncodeSql(sw.REPTYPEID)); } if (string.IsNullOrEmpty(sw.NAME) == false) { sb.AppendFormat("and NAME like '%{0}%'", ClsSql.EncodeSql(sw.NAME)); } if (string.IsNullOrEmpty(sw.ADDRESS) == false) { sb.AppendFormat("and ADDRESS = '{0}'", ClsSql.EncodeSql(sw.ADDRESS)); } 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(4, 11) == "xxxxxxxxxxx") //单独市 { sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,15) = '{0}')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 4) + "00000000000")); } else if (sw.BYORGNO.Substring(6, 9) == "xxxxxxxxx") //获取所有县的 { 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 if (sw.BYORGNO.Substring(12, 3) == "000") //获取说有村的 { sb.AppendFormat(" AND (SUBSTRING(BYORGNO,1,12) = '{0}'or BYORGNO is null or BYORGNO='')", ClsSql.EncodeSql(sw.BYORGNO.Substring(0, 12))); } else { sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } } if (string.IsNullOrEmpty(sw.RESPONSIBLEMAN) == false) { sb.AppendFormat("and RESPONSIBLEMAN = '{0}'", ClsSql.EncodeSql(sw.RESPONSIBLEMAN)); } if (string.IsNullOrEmpty(sw.LINKWAY) == false) { sb.AppendFormat("and LINKWAY = '{0}'", ClsSql.EncodeSql(sw.LINKWAY)); } string sql = ("select DCREPOSITORYID,REPTYPEID,NAME,ADDRESS,BYORGNO,RESPONSIBLEMAN,LINKWAY,JD,WD") + sb.ToString() + ("order by BYORGNO,DCREPOSITORYID desc"); 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]); }