Ejemplo n.º 1
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static IEnumerable <WILD_BOTANYDYNAMICPROP_Model> getListModel(WILD_BOTANYDYNAMICPROP_SW sw)
        {
            var       result = new List <WILD_BOTANYDYNAMICPROP_Model>();
            DataTable dt     = BaseDT.WILD_BOTANYDYNAMICPROP.getDT(sw);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                WILD_BOTANYDYNAMICPROP_Model m = new WILD_BOTANYDYNAMICPROP_Model();
                m.WILD_BOTANYDYNAMICPROPID = dt.Rows[i]["WILD_BOTANYDYNAMICPROPID"].ToString();
                m.BIOLOGICALTYPECODE       = dt.Rows[i]["BIOLOGICALTYPECODE"].ToString();
                m.DYNAMICPROPCODE          = dt.Rows[i]["DYNAMICPROPCODE"].ToString();
                m.DYNAMICPROPCONTENT       = dt.Rows[i]["DYNAMICPROPCONTENT"].ToString();
                result.Add(m);
            }
            dt.Clear();
            dt.Dispose();
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取单条记录
        /// </summary>
        /// <param name="sw">参见模型</param>
        /// <returns>参见模型</returns>
        public static WILD_BOTANYDYNAMICPROP_Model getModel(WILD_BOTANYDYNAMICPROP_SW sw)
        {
            DataTable dt = BaseDT.WILD_BOTANYDYNAMICPROP.getDT(sw);
            WILD_BOTANYDYNAMICPROP_Model m = new WILD_BOTANYDYNAMICPROP_Model();

            if (dt.Rows.Count > 0)
            {
                int i = 0;
                //数据库表字段
                m.WILD_BOTANYDYNAMICPROPID = dt.Rows[i]["WILD_BOTANYDYNAMICPROPID"].ToString();
                m.BIOLOGICALTYPECODE       = dt.Rows[i]["BIOLOGICALTYPECODE"].ToString();
                m.DYNAMICPROPCODE          = dt.Rows[i]["DYNAMICPROPCODE"].ToString();
                m.DYNAMICPROPCONTENT       = dt.Rows[i]["DYNAMICPROPCONTENT"].ToString();
                //扩充字段
            }
            dt.Clear();
            dt.Dispose();
            return(m);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="m">参见模型</param>
 /// <returns>参见模型</returns>
 public static Message Manager(WILD_BOTANYDYNAMICPROP_Model m)
 {
     return(BaseDT.WILD_BOTANYDYNAMICPROP.Save(m));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="m">参见模型</param>
        /// <returns>参见模型</returns>
        public static Message Save(WILD_BOTANYDYNAMICPROP_Model m)
        {
            List <string> sqllist = new List <string>();

            string[] arrDYNAMICPROPCODE    = m.DYNAMICPROPCODE.Split(',');
            string[] arrDYNAMICPROPCONTENT = m.DYNAMICPROPCONTENT.Split(',');
            if (arrDYNAMICPROPCODE.Length - 1 > 0)
            {
                #region 先删除
                StringBuilder sbDelete = new StringBuilder();
                sbDelete.AppendFormat("delete from WILD_BOTANYDYNAMICPROP where 1=1");
                sbDelete.AppendFormat(" and BIOLOGICALTYPECODE='{0}'", m.BIOLOGICALTYPECODE);
                DataBaseClass.ExeSql(sbDelete.ToString());
                #endregion

                #region 再更新
                StringBuilder sbInsert = new StringBuilder();
                sbInsert.AppendFormat("INSERT INTO WILD_BOTANYDYNAMICPROP(BIOLOGICALTYPECODE, DYNAMICPROPCODE, DYNAMICPROPCONTENT)");
                for (int i = 0; i < arrDYNAMICPROPCODE.Length - 1; i++)
                {
                    #region 更新
                    if (isExists(new WILD_BOTANYDYNAMICPROP_SW {
                        BIOLOGICALTYPECODE = m.BIOLOGICALTYPECODE, DYNAMICPROPCODE = arrDYNAMICPROPCODE[i]
                    }))
                    {
                        StringBuilder sbUpdate = new StringBuilder();
                        sbUpdate.AppendFormat("UPDATE WILD_BOTANYDYNAMICPROP SET ");
                        sbUpdate.AppendFormat(" DYNAMICPROPCONTENT={0},", ClsSql.saveNullField(arrDYNAMICPROPCONTENT[i]));
                        sbUpdate.AppendFormat(" where BIOLOGICALTYPECODE= '{0}'", ClsSql.EncodeSql(m.BIOLOGICALTYPECODE));
                        sbUpdate.AppendFormat(" and DYNAMICPROPCODE= '{0}'", ClsSql.EncodeSql(arrDYNAMICPROPCODE[i]));
                        sqllist.Add(sbUpdate.ToString());
                    }
                    #endregion

                    #region 添加
                    else
                    {
                        sbInsert.AppendFormat(" select '{0}'", ClsSql.EncodeSql(m.BIOLOGICALTYPECODE));
                        sbInsert.AppendFormat(",'{0}'", ClsSql.EncodeSql(arrDYNAMICPROPCODE[i]));
                        sbInsert.AppendFormat(",{0}", ClsSql.saveNullField(arrDYNAMICPROPCONTENT[i]));
                        sbInsert.AppendFormat(" UNION ALL ");
                    }
                    #endregion
                }
                string insertStr = sbInsert.ToString();
                if (insertStr.Contains(" UNION ALL "))
                {
                    insertStr = insertStr.Substring(0, insertStr.Length - 10);
                    sqllist.Add(insertStr);
                }
                #endregion
            }
            var y = DataBaseClass.ExecuteSqlTran(sqllist);
            if (y >= 0)
            {
                return(new Message(true, "保存成功!", ""));
            }
            else
            {
                return(new Message(false, "保存失败,事物回滚机制!", ""));
            }
        }