protected bool UpdateByCondition(string condition)
        {
            ChangePropertys.Remove(_TEMPLATE_ID);
            if (ChangePropertys.Count == 0)
            {
                return(true);
            }

            StringBuilder sql = new StringBuilder();

            sql.AppendLine("UPDATE TSMS_TEMPLATE SET");
            while (ChangePropertys.MoveNext())
            {
                sql.AppendFormat(" {0}{1}=:{1} ", (ChangePropertys.CurrentIndex == 0 ? string.Empty : ","), ChangePropertys.Current);
                AddParameter(ChangePropertys.Current, DataRow[ChangePropertys.Current]);
            }
            sql.Append(" WHERE TEMPLATE_ID=:TEMPLATE_ID");
            AddParameter(_TEMPLATE_ID, DataRow[_TEMPLATE_ID]);
            if (!string.IsNullOrEmpty(condition))
            {
                sql.AppendLine(" AND " + condition);
            }
            bool result = base.UpdateBySql(sql.ToString());

            ChangePropertys.Clear();
            return(result);
        }
Exemple #2
0
        protected bool UpdateByCondition(string condition)
        {
            //移除主键标记
            ChangePropertys.Remove(_id);

            if (ChangePropertys.Count == 0)
            {
                return(true);
            }

            StringBuilder sql = new StringBuilder();

            sql.AppendLine("update tmp_late_price set");
            while (ChangePropertys.MoveNext())
            {
                sql.AppendFormat(" {0}{1}=?{1} ", (ChangePropertys.CurrentIndex == 0 ? string.Empty : ","), ChangePropertys.Current);
                AddParameter(ChangePropertys.Current, DataRow[ChangePropertys.Current]);
            }
            sql.AppendLine(" where id=?id");
            AddParameter(_id, DataRow[_id]);
            if (!string.IsNullOrEmpty(condition))
            {
                sql.AppendLine(" and " + condition);
            }

            bool result = base.UpdateBySql(sql.ToString());

            ChangePropertys.Clear();
            return(result);
        }
        public bool Update(Dictionary <Tauth_ScopeCollection.Field, object> conditionDic)
        {
            if (conditionDic.Count <= 0)
            {
                return(false);
            }
            ChangePropertys.Remove(_SCOPE_ID);
            if (ChangePropertys.Count == 0)
            {
                return(true);
            }

            StringBuilder sql = new StringBuilder();

            sql.AppendLine("UPDATE TAUTH_SCOPE SET");
            while (ChangePropertys.MoveNext())
            {
                sql.AppendFormat(" {0}{1}=:TO_{1} ", (ChangePropertys.CurrentIndex == 0 ? string.Empty : ","), ChangePropertys.Current);
                AddParameter("TO_" + ChangePropertys.Current, DataRow[ChangePropertys.Current]);
            }
            sql.Append(" WHERE SCOPE_ID=:SCOPE_ID ");
            AddParameter(_SCOPE_ID, DataRow[_SCOPE_ID]);
            foreach (Tauth_ScopeCollection.Field key in conditionDic.Keys)
            {
                if (Tauth_ScopeCollection.Field.Scope_Id == key)
                {
                    continue;
                }

                object value = conditionDic[key];
                string name  = string.Concat("condition_", key);
                sql.Append(" AND ").Append(key.ToString().ToUpper()).Append("=:").Append(name.ToUpper());
                AddParameter(name, value);
            }
            return(UpdateBySql(sql.ToString()));
        }