/// <summary> /// 获取数据列表 /// </summary> /// <param name="sw">参见模型</param> /// <returns>参见模型</returns> public static IEnumerable <WILD_LOCALBOTANY_Model> getListModel(WILD_LOCALBOTANY_SW sw) { var result = new List <WILD_LOCALBOTANY_Model>(); DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); //获取单位 DataTable dtBiolo = BaseDT.T_SYS_BIOLOGICALTYPE.getDT(new T_SYS_BIOLOGICALTYPE_SW()); DataTable dt = BaseDT.WILD_LOCALBOTANY.getDT(sw); for (int i = 0; i < dt.Rows.Count; i++) { WILD_LOCALBOTANY_Model m = new WILD_LOCALBOTANY_Model(); m.WILD_LOCALBOTANYID = dt.Rows[i]["WILD_LOCALBOTANYID"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ORGNONAME = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.BIOLOGICALTYPECODE = dt.Rows[i]["BIOLOGICALTYPECODE"].ToString(); m.BIOLOGICALTYPECODENAME = BaseDT.T_SYS_BIOLOGICALTYPE.getName(dtBiolo, m.BIOLOGICALTYPECODE); m.PESTKECODE = m.BIOLOGICALTYPECODE.Substring(0, 10) + "0000"; m.PESTKENAME = BaseDT.T_SYS_BIOLOGICALTYPE.getName(dtBiolo, m.PESTKECODE); m.PESTSHUCODE = m.BIOLOGICALTYPECODE.Substring(0, 12) + "00"; m.PESTSHUNAME = BaseDT.T_SYS_BIOLOGICALTYPE.getName(dtBiolo, m.PESTSHUCODE); result.Add(m); } dtORG.Clear(); dtORG.Dispose(); dtBiolo.Clear(); dtBiolo.Dispose(); dt.Clear(); dt.Dispose(); return(result); }
/// <summary> /// 获取单条记录 /// </summary> /// <param name="sw">参见模型</param> /// <returns>参见模型</returns> public static WILD_LOCALBOTANY_Model getModel(WILD_LOCALBOTANY_SW sw) { DataTable dt = BaseDT.WILD_LOCALBOTANY.getDT(sw); DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); //获取单位 DataTable dtBiolo = BaseDT.T_SYS_BIOLOGICALTYPE.getDT(new T_SYS_BIOLOGICALTYPE_SW()); WILD_LOCALBOTANY_Model m = new WILD_LOCALBOTANY_Model(); if (dt.Rows.Count > 0) { int i = 0; m.WILD_LOCALBOTANYID = dt.Rows[i]["WILD_LOCALBOTANYID"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ORGNONAME = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.BIOLOGICALTYPECODE = dt.Rows[i]["BIOLOGICALTYPECODE"].ToString(); m.BIOLOGICALTYPECODENAME = BaseDT.T_SYS_BIOLOGICALTYPE.getName(dtBiolo, m.BIOLOGICALTYPECODE); m.PESTKECODE = m.BIOLOGICALTYPECODE.Substring(0, 10) + "0000"; m.PESTKENAME = BaseDT.T_SYS_BIOLOGICALTYPE.getName(dtBiolo, m.PESTKECODE); m.PESTSHUCODE = m.BIOLOGICALTYPECODE.Substring(0, 12) + "00"; m.PESTSHUNAME = BaseDT.T_SYS_BIOLOGICALTYPE.getName(dtBiolo, m.PESTSHUCODE); } dtORG.Clear(); dtORG.Dispose(); dtBiolo.Clear(); dtBiolo.Dispose(); dt.Clear(); dt.Dispose(); return(m); }
/// <summary> /// 管理 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Manager(WILD_LOCALBOTANY_Model m) { if (m.opMethod == "Add") { Message msg = BaseDT.WILD_LOCALBOTANY.Add(m); return(new Message(msg.Success, msg.Msg, msg.Url)); } else if (m.opMethod == "Del") { Message msg = BaseDT.WILD_LOCALBOTANY.Del(m); return(new Message(msg.Success, msg.Msg, msg.Url)); } return(new Message(false, "无效操作", "")); }
/// <summary> /// 删除 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Del(WILD_LOCALBOTANY_Model m) { List <string> sqllist = new List <string>(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("Delete From WILD_LOCALBOTANY WHERE 1=1 "); sb.AppendFormat(" AND BYORGNO = '{0}'", ClsSql.EncodeSql(m.BYORGNO)); sb.AppendFormat(" AND BIOLOGICALTYPECODE IN ({0})", ClsSql.SwitchStrToSqlIn(m.BIOLOGICALTYPECODE)); sqllist.Add(sb.ToString()); var y = DataBaseClass.ExecuteSqlTran(sqllist); if (y > 0) { return(new Message(true, "删除成功!", "")); } else { return(new Message(false, "删除失败,事物回滚!", "")); } }
/// <summary> /// 添加 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Add(WILD_LOCALBOTANY_Model m) { List <string> sqllist = new List <string>(); string[] arrBIOLOGICALTYPECODE = m.BIOLOGICALTYPECODE.Split(','); StringBuilder sb = new StringBuilder(); if (arrBIOLOGICALTYPECODE.Length > 0) { sb.AppendFormat("INSERT INTO WILD_LOCALBOTANY(BYORGNO, BIOLOGICALTYPECODE) "); for (int i = 0; i < arrBIOLOGICALTYPECODE.Length; i++) { if (!isExists(new WILD_LOCALBOTANY_SW { BYORGNO = m.BYORGNO, BIOLOGICALTYPECODE = arrBIOLOGICALTYPECODE[i] })) { sb.AppendFormat(" select '{0}'", ClsSql.EncodeSql(m.BYORGNO)); sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(arrBIOLOGICALTYPECODE[i])); sb.AppendFormat(" UNION ALL "); } } string insertStr = sb.ToString(); if (insertStr.Contains(" UNION ALL ")) { insertStr = insertStr.Substring(0, insertStr.Length - 10); sqllist.Add(insertStr); } } var y = DataBaseClass.ExecuteSqlTran(sqllist); if (y > 0) { return(new Message(true, "添加成功!", "")); } else { return(new Message(false, "添加失败,事物回滚!", "")); } }