Ejemplo n.º 1
0
        protected virtual IDecoderItem CreateItem(string code, params object[] args)
        {
            TkDbContext context;
            bool        createContext;

            GetContext(args, out context, out createContext);
            try
            {
                DataRow row = FetchRow(code, context, fDataSet);
                if (row == null)
                {
                    return(null);
                }
                DataColumnCollection columns = row.Table.Columns;
                DataRowDecoderItem   result  = new DataRowDecoderItem(columns, row,
                                                                      DecoderConst.CODE_NICK_NAME, fExpression, fDisplayExpression);
                return(result);
            }
            finally
            {
                if (createContext)
                {
                    context.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        public override IDecoderItem Decode(string code, params object[] args)
        {
            FillData(args);

            DataRow row;

            try
            {
                row = fDataTable.Rows.Find(code);
            }
            catch
            {
                row = null;
            }
            if (row == null)
            {
                return(null);
            }
            else
            {
                DataRowDecoderItem item = new DataRowDecoderItem(fDataTable.Columns, row,
                                                                 DecoderConst.CODE_NICK_NAME, DecoderConst.NAME_NICK_NAME);
                return(item);
            }
        }
Ejemplo n.º 3
0
        public override IDecoderItem[] SearchByName(string name, params object[] args)
        {
            TkDbContext context;
            bool        createContext;

            GetContext(args, out context, out createContext);

            try
            {
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, NameField, name);
                DataTable     table   = FetchRows(context, fDataSet, builder, 2);
                if (table == null || table.Rows.Count == 0)
                {
                    return(null);
                }
                IDecoderItem[]       result  = new IDecoderItem[table.Rows.Count];
                int                  index   = 0;
                DataColumnCollection columns = table.Columns;
                foreach (DataRow row in table.Rows)
                {
                    result[index++] = new DataRowDecoderItem(columns, row,
                                                             DecoderConst.CODE_NICK_NAME, fExpression, fDisplayExpression);
                }

                return(result);
            }
            finally
            {
                if (createContext)
                {
                    context.Dispose();
                }
            }
        }