예제 #1
0
        public List <DictionaryEntry> GetDataMapDistinct(string valuefield, string textfield, string condition)
        {
            if (valuefield.CompareTo(textfield) == 0)
            {
                TableManager.SetOrder(TableManager.GetParameterName(valuefield));
                DataTable table = TableManager.Select(this.GetTableName(), "distinct " + valuefield, condition);
                List <DictionaryEntry> maplist = new List <DictionaryEntry>();
                foreach (DataRow row in table.Rows)
                {
                    if (Utils.NvStr(row[0]) != "")
                    {
                        maplist.Add(new DictionaryEntry(Utils.NvStr(row[0]), Utils.NvStr(row[0])));
                    }
                }

                return(maplist);
            }
            else
            {
                TableManager.SetOrder(TableManager.GetParameterName(valuefield) + "," + TableManager.GetParameterName(textfield));
                DataTable table = TableManager.Select(this.GetTableName(), "distinct " + valuefield + "," + textfield, condition);
                List <DictionaryEntry> maplist = new List <DictionaryEntry>();
                foreach (DataRow row in table.Rows)
                {
                    maplist.Add(new DictionaryEntry(Utils.NvStr(row[0]), Utils.NvStr(row[1])));
                }

                return(maplist);
            }
        }
예제 #2
0
        public virtual int Create()
        {
            Type t = this.GetType();

            PropertyInfo[] props = t.GetProperties();
            PropertyInfo   auto_increase_field = null;

            List <MyField> fields = new List <MyField>();

            foreach (PropertyInfo p in props)
            {
                string fName = p.Name.ToUpper();
                if (!this.IsReadOnlyField(fName))
                {
                    if (fName.ToLower() == "createtime" ||
                        fName.ToLower() == "updatetime")
                    {
                        DateTime now = TableManager.DBServerTime();
                        fields.Add(new MyField(fName, now, p.PropertyType));
                        p.GetSetMethod().Invoke(this, new Object[] { now });
                    }
                    else if (fName.ToLower() == "createuser" ||
                             fName.ToLower() == "updateuser")
                    {
                        fields.Add(new MyField(fName, Global.g_username, p.PropertyType));
                        p.GetSetMethod().Invoke(this, new Object[] { Global.g_username });
                    }
                    else
                    {
                        Object val = p.GetGetMethod().Invoke(this, new Object[] { });
                        if (val == null)
                        {
                            fields.Add(new MyField(fName, DBNull.Value, p.PropertyType));
                        }
                        else
                        {
                            fields.Add(new MyField(fName, val, p.PropertyType));
                        }
                    }
                }
                else if (fName.ToUpper() == "ID")
                {
                    auto_increase_field = p;
                }
            }

            if (auto_increase_field != null)
            {
                int id;
                int ret = TableManager.Insert(this.GetTableName(), fields.ToArray(), out id);
                if (ret > 0)
                {
                    auto_increase_field.GetSetMethod().Invoke(this, new Object[] { id });
                }
                return(ret);
            }
            else
            {
                return(TableManager.Insert(this.GetTableName(), fields.ToArray()));
            }
        }
예제 #3
0
 public virtual int Delete(params MyField[] paramfileds)
 {
     return(TableManager.Delete(this.GetTableName(), paramfileds));
 }
예제 #4
0
 public MyField(string fieldName, object fieldValue, Type type)
 {
     this._fieldName  = fieldName;
     this._fieldValue = fieldValue;
     this._dataType   = TableManager.TypeToDbType(type);
 }