示例#1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="m">参见模型</param>
        /// <returns>参见模型</returns>
        public static Message Del(T_ALL_AREA_Model m)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("delete T_ALL_AREA");
            if (m.AREACODE.Substring(2, 7) == "0000000")
            {
                sb.AppendFormat(" where substring(AREACODE,1,2)= '{0}'", ClsSql.EncodeSql(m.AREACODE.Substring(0, 2)));
            }
            else if (m.AREACODE.Substring(4, 5) == "00000")
            {
                sb.AppendFormat(" where substring(AREACODE,1,4)= '{0}'", ClsSql.EncodeSql(m.AREACODE.Substring(0, 4)));
            }
            else if (m.AREACODE.Substring(6, 3) == "000")
            {
                sb.AppendFormat(" where substring(AREACODE,1,6)= '{0}'", ClsSql.EncodeSql(m.AREACODE.Substring(0, 6)));
            }
            else
            {
                sb.AppendFormat(" where substring(AREACODE,1,{0})= '{1}'", ClsSql.EncodeSql(m.AREACODE).Length.ToString(), ClsSql.EncodeSql(m.AREACODE));
            }
            bool bln = DataBaseClass.ExeSql(sb.ToString());

            if (bln == true)
            {
                return(new Message(true, "删除成功!", m.returnUrl));
            }
            else
            {
                return(new Message(false, "删除失败,请检查各输入框是否正确!", m.returnUrl));
            }
        }
示例#2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="m">参见模型</param>
        /// <returns>参见模型</returns>
        public static Message Add(T_ALL_AREA_Model m)
        {
            if (isExists(new T_ALL_AREA_SW {
                AREACODE = m.AREACODE,
            }) == true)
            {
                return(new Message(false, "添加失败,该区划编码已存在!", ""));
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("INSERT INTO  T_ALL_AREA(AREACODE, AREANAME, AREAJC, JD, WD ) OUTPUT INSERTED.AREAID ");
            sb.AppendFormat(" VALUES(");
            sb.AppendFormat(" '{0}'", ClsSql.EncodeSql(m.AREACODE));
            sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.AREANAME));
            sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.AREAJC));
            sb.AppendFormat(" ,{0}", ClsSql.saveNullField(m.JD));
            sb.AppendFormat(" ,{0}", ClsSql.saveNullField(m.WD));
            sb.AppendFormat(")");
            try
            {
                string sId = DataBaseClass.ReturnSqlField(sb.ToString());
                if (sId != "")
                {
                    return(new Message(true, "添加成功!", m.returnUrl + "," + sId));
                }
                else
                {
                    return(new Message(false, "添加失败!", m.returnUrl));
                }
            }
            catch
            {
                return(new Message(false, "添加失败!", m.returnUrl));
            }
        }
示例#3
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="sw">参见条件模型T_ALL_AREA_SW</param>
        /// <returns>参见模型T_ALL_AREA_Model</returns>
        public static IEnumerable <T_ALL_AREA_Model> getListModel(T_ALL_AREA_SW sw)
        {
            var       result = new List <T_ALL_AREA_Model>();
            DataTable dt     = BaseDT.T_ALL_AREA.getDT(sw);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                T_ALL_AREA_Model m = new T_ALL_AREA_Model();
                m.AREACODE = dt.Rows[i]["AREACODE"].ToString();
                m.AREAID   = dt.Rows[i]["AREAID"].ToString();
                m.AREANAME = dt.Rows[i]["AREANAME"].ToString();
                m.AREAJC   = dt.Rows[i]["AREAJC"].ToString();
                m.JD       = dt.Rows[i]["JD"].ToString();
                m.WD       = dt.Rows[i]["WD"].ToString();
                result.Add(m);
            }
            dt.Clear();
            dt.Dispose();
            return(result);
        }
示例#4
0
        /// <summary>
        /// 获取单条记录
        /// </summary>
        /// <param name="sw">参见条件模型T_ALL_AREA_SW</param>
        /// <returns>参见模型T_ALL_AREA_Model</returns>
        public static T_ALL_AREA_Model getModel(T_ALL_AREA_SW sw)
        {
            DataTable        dt = BaseDT.T_ALL_AREA.getDT(sw);
            T_ALL_AREA_Model m  = new T_ALL_AREA_Model();

            if (dt.Rows.Count > 0)
            {
                int i = 0;
                //数据库表字段
                m.AREAID   = dt.Rows[i]["AREAID"].ToString();
                m.AREACODE = dt.Rows[i]["AREACODE"].ToString();
                m.AREANAME = dt.Rows[i]["AREANAME"].ToString();
                m.AREAJC   = dt.Rows[i]["AREAJC"].ToString();
                m.JD       = dt.Rows[i]["JD"].ToString();
                m.WD       = dt.Rows[i]["WD"].ToString();
                //扩充字段
            }
            dt.Clear();
            dt.Dispose();
            return(m);
        }
示例#5
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="m">参见模型</param>
        /// <returns>参见模型</returns>
        public static Message Mdy(T_ALL_AREA_Model m)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("UPDATE T_ALL_AREA SET ");
            sb.AppendFormat(" AREANAME='{0}'", ClsSql.EncodeSql(m.AREANAME));
            sb.AppendFormat(",AREACODE='{0}'", ClsSql.EncodeSql(m.AREACODE));
            sb.AppendFormat(",AREAJC='{0}'", ClsSql.EncodeSql(m.AREAJC));
            sb.AppendFormat(",JD={0}", ClsSql.saveNullField(m.JD));
            sb.AppendFormat(",WD={0}", ClsSql.saveNullField(m.WD));
            sb.AppendFormat(" where AREAID= '{0}'", ClsSql.EncodeSql(m.AREAID));
            bool bln = DataBaseClass.ExeSql(sb.ToString());

            if (bln == true)
            {
                return(new Message(true, "修改成功!", m.returnUrl + "," + m.AREAID));
            }
            else
            {
                return(new Message(false, "修改失败,请检查各输入框是否正确!", m.returnUrl));
            }
        }
示例#6
0
 /// <summary>
 /// 增删改
 /// </summary>
 /// <param name="m">参见模型T_ALL_AREA_Model</param>
 /// <returns>参见模型Message</returns>
 public static Message Manager(T_ALL_AREA_Model m)
 {
     if (m.opMethod == "Add")
     {
         Message msgArea = BaseDT.T_ALL_AREA.Add(m);
         if (msgArea.Success == false)
         {
             return(new Message(msgArea.Success, msgArea.Msg, ""));
         }
         return(new Message(msgArea.Success, msgArea.Msg, msgArea.Url));
     }
     if (m.opMethod == "Mdy")
     {
         Message msgArea = BaseDT.T_ALL_AREA.Mdy(m);
         return(new Message(msgArea.Success, msgArea.Msg, msgArea.Url));
     }
     if (m.opMethod == "Del")
     {
         return(BaseDT.T_ALL_AREA.Del(m));
     }
     return(new Message(false, "无效操作", m.returnUrl));
 }