Example #1
0
 public void buildFilterFilter(DBFilter filter)
 {
     foreach (DBTerm t in terms)
     {
         filter.add(t);
     }
     foreach (DBTerm t in filterTerms)
     {
         filter.add(t);
     }
     foreach (SearchBinder binder in binders)
     {
         binder.buildFilterFilter(filter);
     }
 }
Example #2
0
        public ArrayList Select(DBFilter filter, DBManager db)
        {
            DateTime startTime = DateTime.Now;

            IDbCommand command = CreateSelectCommand(db.selectSQLHeader, filter);

            ArrayList result = ExecuteToArrayList(command, db.fields, db.DBObjectType);

            // remove the makeClean() so that the update function will update all the field in db every time
            // if select() and update() is called continuously
            // e.g use force decrypt function
            //foreach (DBObject obj in result)
            //    obj.makeClean();

            return(result);
        }
 public override bool buildFilter(DBFilter filter)
 {
     if (c.Value.Length > 0)
     {
         string v = c.Value;
         if (v.Equals(Common.EMPTY_STRING))
         {
             v = "";
         }
         filter.add(new Match(name, op, v.Trim()));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #4
0
        public List <WFSelectValue> getValues(DatabaseConnection DBConn, DBFilter filter, CultureInfo ci)
        {
            List <WFSelectValue> list = new List <WFSelectValue>();
            ResourceManager      rm   = DBUtils.getResourceManager();

            for (int i = 0; i != values.Length; i++)
            {
                string s = rm.GetString(display[i], ci);
                if (s == null)
                {
                    s = display[i];
                }
                WFSelectValue sv = new WFSelectValue(values[i], s);
                list.Add(sv);
            }
            return(list);
        }
Example #5
0
        public bool createFilter(DBFilter f)
        {
            bool result = false;

            foreach (DBTerm t in terms)
            {
                f.add(t);
            }

            foreach (SearchBinder b in binders)
            {
                if (b.buildFilter(f))
                {
                    result = true;
                }
            }
            return(result);
        }
        public override bool buildFilter(DBFilter filter)
        {
            string v = c.Value;

            v = v.Trim();
            if (v.Equals(""))
            {
                OR or = new OR();
                or.add(new Match(name, op, ""));
                or.add(new Match(name, op, null));
                filter.add(or);
            }
            else
            {
                filter.add(new Match(name, op, v));
            }
            return(true);
        }
Example #7
0
        public DbCommand CreateDeleteCommand(string DeleteQueryHeader, DBFilter dbFilter)
        {
            int commandIndex  = 1;
            int buildSQLIndex = 1;

            string    query   = DeleteQueryHeader;
            DbCommand command = CreateCommand();

            command.CommandType = CommandType.Text;

            if (dbFilter != null)
            {
                query += dbFilter.getWhereClause(this, false, buildSQLIndex, out buildSQLIndex);
                dbFilter.setParams(commandIndex, command);
            }
            command.CommandText = query;

            return(command);
        }
Example #8
0
 public IN(string searchFieldName, int[] ItemArray)
 {
     this.filter = null;
     this.selectQueryOrItemList = string.Empty;
     foreach (int i in ItemArray)
     {
         if (string.IsNullOrEmpty(selectQueryOrItemList))
         {
             selectQueryOrItemList = i.ToString();
         }
         else
         {
             // Start 0000111, Miranda, 2015-01-03
             selectQueryOrItemList += ("," + i.ToString());
         }
     }
     // End 0000111, Miranda, 2015-01-03
     this.searchFieldName = searchFieldName;
 }
Example #9
0
        public override bool buildFilter(DBFilter filter)
        {
            if ((hasNotSelected && c.SelectedIndex > 0) || (!hasNotSelected && c.SelectedIndex >= 0))
            {
                string column;
                column = fieldName;

                string s = c.SelectedValue;
                if (s.Equals(Common.EMPTY_STRING))
                {
                    return(false);
                }
                //				object v=f.parseValue(s);
                filter.add(new Match(column, s));
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        public List <WFSelectValue> getValues(DatabaseConnection DBConn, DBFilter filter, CultureInfo ci)
        {
            if (terms.Count > 0)
            {
                if (filter == null)
                {
                    filter = new DBFilter();
                }
                foreach (DBTerm t in terms)
                {
                    filter.add(t);
                }
            }
            if (!string.IsNullOrEmpty(sortField))
            {
                if (filter == null)
                {
                    filter = new DBFilter();
                }

                filter.add(sortField, true);
            }

            IDbCommand command = DBConn.CreateSelectCommand("SELECT DISTINCT " + keyField + " K, " + nameField + " V," + sortField + " FROM " + tableName, filter);

            DataTable table = DBConn.ExecuteToDataTable(command);

            List <WFSelectValue> list = new List <WFSelectValue>();

            foreach (DataRow row in table.Rows)
            {
                string        name = row["V"].ToString().Trim();
                string        val  = row["K"].ToString().Trim();
                WFSelectValue sv   = new WFSelectValue(val, name);
                list.Add(sv);
            }
            return(list);
        }
Example #11
0
        public DbCommand CreateSelectCommand(string SelectQueryWithoutConstraint, DBFilter dbFilter, ListInfo info)
        {
            int commandIndex  = 1;
            int buildSQLIndex = 1;

            string query = SelectQueryWithoutConstraint;

            DbCommand command = CreateCommand();

            command.CommandType = CommandType.Text;

            if (dbFilter != null)
            {
                query += dbFilter.getWhereClause(this, false, buildSQLIndex, out buildSQLIndex);
                query += dbFilter.getGroupCluase();
                query += dbFilter.getOrderClause(info);
                dbFilter.setParams(commandIndex, command);
            }
            command.CommandText = query;


            return(command);
        }
Example #12
0
 public DropDownVLBinder(DBManager db, DropDownList c, WFValueList vl, DBFilter filter)
     : this(db, c, vl, filter, c.ID)
 {
 }
Example #13
0
 public ArrayList select(HROne.DataAccess.DatabaseConnection dbAccess, DBFilter filter)
 {
     return(dbAccess.Select(filter, this));
 }
Example #14
0
 public bool delete(HROne.DataAccess.DatabaseConnection dbAccess, DBFilter filter)
 {
     return(dbAccess.Delete(filter, this));
 }
Example #15
0
        public virtual bool updateByTemplate(HROne.DataAccess.DatabaseConnection dbAccess, DBObject obj, DBFilter filter)
        {
            bool result = dbAccess.UpdateByTemplate(obj, dbclass.tableName, fields, filter);

            return(result);
        }
Example #16
0
 public virtual void buildFilterFilter(DBFilter filter)
 {
     buildFilter(filter);
 }
Example #17
0
 public IN(string searchFieldName, string[] ItemArray)
 {
     this.filter = null;
     this.selectQueryOrItemList = "'" + string.Join("','", ItemArray) + "'";
     this.searchFieldName       = searchFieldName;
 }
Example #18
0
 public static void loadValues(DatabaseConnection DBConn, ListControl c, WFValueList vl, DBFilter filter)
 {
     loadValues(DBConn, c, vl, filter, null, null, "--");
 }
Example #19
0
 public Exists(string tableName, DBFilter filter, bool notExist)
     : this("*", tableName, filter, notExist)
 {
 }
Example #20
0
        //public DbCommand CreateSelectCommand(string FieldList, string TableList, DBFilter dbFilter)
        //{

        //    string query = "SELECT " + FieldList + " FROM " + TableList;
        //    return CreateSelectCommand(query, dbFilter, null);
        //}

        private DbCommand CreateUpdateCommand(string tablename, DBObject obj, ICollection <DBField> dbFieldList, DBFilter dbFilter)
        {
            int commandIndex  = 1;
            int buildSQLIndex = 1;

            DbCommand command = CreateCommand();

            command.CommandType = CommandType.Text;

            string updateField = string.Empty;

            foreach (DBField dbField in dbFieldList)
            {
                if (!dbField.isAuto)
                {
                    if (obj.isModified(dbField.name))
                    {
                        object value = dbField.property.GetValue(obj, null);
                        if (value is string)
                        {
                            value = ((string)value).Trim();
                        }
                        if (dbField.transcoder != null)
                        {
                            value = dbField.transcoder.toDB(value);
                        }


                        string fieldParameterName = getQueryValueParameterName(buildSQLIndex.ToString());
                        buildSQLIndex++;
                        string valueParameterName = "@" + commandIndex++;
                        string assignValue        = dbField.columnName + " = " + fieldParameterName;

                        if (updateField.Equals(string.Empty))
                        {
                            updateField = " SET " + assignValue;
                        }
                        else
                        {
                            updateField += ", " + assignValue;
                        }

                        SetUpdateCommandDBParameter(command, valueParameterName, value);
                    }
                }
            }
            if (!string.IsNullOrEmpty(updateField))
            {
                string query = "UPDATE " + tablename + updateField;

                if (dbFilter != null)
                {
                    query += dbFilter.getWhereClause(this, false, buildSQLIndex, out buildSQLIndex);
                    dbFilter.setParams(commandIndex, command);
                }
                command.CommandText = query;

                return(command);
            }
            else
            {
                return(null);
            }
        }
Example #21
0
 public int count(HROne.DataAccess.DatabaseConnection dbAcces, DBFilter filter)
 {
     return(dbAcces.Count(filter, this));
 }
 public override bool updateByTemplate(DatabaseConnection dbAccess, DBObject obj, DBFilter filter)
 {
     if (obj is BaseObjectWithRecordInfo)
     {
         BaseObjectWithRecordInfo tmpObj = (BaseObjectWithRecordInfo)obj;
         tmpObj.RecordLastModifiedDateTime = AppUtils.ServerDateTime();
         if (dbAccess is DatabaseConnectionWithAudit)
         {
             tmpObj.RecordLastModifiedBy = ((DatabaseConnectionWithAudit)dbAccess).UserID;
         }
         else
         {
             tmpObj.RecordLastModifiedBy = 0;
         }
     }
     return(base.updateByTemplate(dbAccess, obj, filter));
 }
Example #23
0
 public DbCommand CreateSelectCommand(string SelectQueryWithoutConstraint, DBFilter dbFilter)
 {
     return(CreateSelectCommand(SelectQueryWithoutConstraint, dbFilter, null));
 }
Example #24
0
        public bool UpdateByTemplate(DBObject templateObj, string table, ICollection <DBField> dbFieldList, DBFilter criteriaFilter)
        {
            DateTime startTime = DateTime.Now;

            IDbCommand command = CreateUpdateCommand(table, templateObj, dbFieldList, criteriaFilter);

            bool result = ExecuteNonQuery(command) > 0 ? true : false;

            return(result);
        }
Example #25
0
 public Exists(string tableName, DBFilter filter)
     : this("*", tableName, filter, false)
 {
 }
Example #26
0
        public static void loadValues(DatabaseConnection DBConn, ListControl c, WFValueList vl, DBFilter filter, CultureInfo ci, string selected, string notSelected)
        {
            //if (selected != null && selected.Equals(string.Empty))
            //    selected = Common.EMPTY_STRING;

            List <WFSelectValue> list = vl.getValues(DBConn, filter, ci);

            c.Items.Clear();

            if (notSelected != null)
            {
                ResourceManager rm = DBUtils.getResourceManager();
                string          s  = rm.GetString(notSelected, ci);
                if (s == null)
                {
                    s = notSelected;
                }
                c.Items.Add(new ListItem(s, string.Empty));
            }

            foreach (WFSelectValue sv in list)
            {
                string key = sv.key;
                //if (key.Equals(""))
                //    key = Common.EMPTY_STRING;

                ListItem i = new ListItem(sv.name, key);
                if (selected != null && sv.key != null && sv.key.Equals(selected))
                {
                    i.Selected = true;
                }
                c.Items.Add(i);
            }

            if (selected != null)
            {
                ListItem item = c.Items.FindByValue(selected);
                if (item != null)
                {
                    c.SelectedValue = item.Value;
                }
            }
        }
Example #27
0
 public Exists(string selectFieldList, string tableName, DBFilter filter)
     : this(selectFieldList, tableName, filter, false)
 {
 }
Example #28
0
 public IN(string searchFieldName, string selectQueryOrItemList, DBFilter filter)
 {
     this.filter = filter;
     this.selectQueryOrItemList = selectQueryOrItemList;
     this.searchFieldName       = searchFieldName;
 }
Example #29
0
 public DropDownVLSearchBinder setFilter(DBFilter filter)
 {
     this.filter = filter;
     return(this);
 }
Example #30
0
 public abstract bool buildFilter(DBFilter filter);