Exemplo n.º 1
0
        public void UpdateObjects(Dictionary <string, object> objs, QueryPageFilter filter)
        {
            string tableName1 = filter.TableName;

            if (TableToTableNameDic != null && TableToTableNameDic.ContainsKey(filter.TableName))
            {
                tableName1 = TableToTableNameDic[filter.TableName];
            }
            if (!DataBaseKyFieldTableDic.ContainsKey(tableName1))
            {
                throw new Exception("缺少表或视图:" + tableName1 + "!请联系开发人员!");
            }
            filter.TableName = tableName1;
            string        whereStr = GetWhereString(filter);
            StringBuilder fields   = new StringBuilder();

            foreach (var item in objs)
            {
                SqlField field;
                var      typeName = DicTableToTableNameFields[filter.TableName][item.Key];
                if (typeName == "datetime" && item.Value != null)
                {
                    var date = DateTime.Parse(item.Value.ToString());
                    field = new SqlField(item.Key, date, CurrPrividerType);
                }
                else
                {
                    field = new SqlField(item.Key, item.Value, CurrPrividerType);
                }
                if (fields.Length > 0)
                {
                    fields.Append(",");
                }
                fields.Append(field.GetKeyEqualsValueString());
            }

            var updateSql = string.Format("update {0} set {1} where {2} ", tableName1, fields.ToString(), whereStr);
            var conn      = DBClassHelper.OpenConnect(CurrConnectionString, SqlHelperFactory.GetSqlPrividerTypeName(CurrPrividerType));
            int count     = DBClassHelper.Execute(updateSql, conn);

            conn.Close();
        }
Exemplo n.º 2
0
        public void DeleteObjects(QueryPageFilter filters)
        {
            string tableName1 = filters.TableName;

            if (TableToTableNameDic != null && TableToTableNameDic.ContainsKey(filters.TableName))
            {
                tableName1 = TableToTableNameDic[filters.TableName];
            }
            if (!DataBaseKyFieldTableDic.ContainsKey(tableName1))
            {
                throw new Exception("缺少表或视图:" + tableName1 + "!请联系开发人员!");
            }
            filters.TableName = tableName1;
            string whereStr = GetWhereString(filters);
            string strSql   = string.Empty;

            strSql = "delete from " + filters.TableName + " where " + whereStr;
            var conn  = DBClassHelper.OpenConnect(CurrConnectionString, SqlHelperFactory.GetSqlPrividerTypeName(CurrPrividerType));
            int count = DBClassHelper.Execute(strSql, conn);

            conn.Close();
        }
Exemplo n.º 3
0
 internal virtual void ExecuteSqlList(StringBuilder sqlList)
 {
     var conn  = DBClassHelper.OpenConnect(CurrConnectionString, SqlHelperFactory.GetSqlPrividerTypeName(CurrPrividerType));
     int count = DBClassHelper.Execute(sqlList.ToString(), conn);
 }