示例#1
0
 public LinkButton()
 {
     CssClass = new SelectField <ButtonCssClass>
     {
         Value = ButtonCssClass.Standard
     };
 }
示例#2
0
 public void Visit(SelectField component)
 {
     component.Field.Accept(this);
     if (!string.IsNullOrEmpty(component.Alias))
     {
         sql.Append($" AS [{component.Alias}]");
     }
 }
示例#3
0
 public static int GetCount(SelectField selectfield)
 {
     SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@TableName", SqlDbType.VarChar, 100), new SqlParameter("@Field", SqlDbType.VarChar, 100), new SqlParameter("@NewField", SqlDbType.VarChar, 100), new SqlParameter("@Condition", SqlDbType.VarChar, 0x1f40) };
     pars[0].Value = selectfield.TableName;
     pars[1].Value = selectfield.Field;
     pars[2].Value = selectfield.NewField;
     pars[3].Value = selectfield.Condition;
     return((int)SqlHelper.GetAllInfo(pars, "SelectField").Tables[0].Rows[0][0]);
 }
        public void TestChooseWithExpectedValue()
        {
            Selenium.Setup(
                o => o.Select(FormXpath + "/select[@id='select']", "Element"));

            var select = new SelectField(Selenium.Object, _form, Id.Is("select"));

            select.Choose("Element");
        }
        public void Content()
        {
            Selenium.Setup(
                o => o.GetSelectedLabel(FormXpath + "/select[@id='select']"));

            var select = new SelectField(Selenium.Object, _form, Id.Is("select"));

            select.Content();
        }
        public void TestBlur()
        {
            Selenium.Setup(
                o => o.FireEvent(FormXpath + "/select[@id='select']", "blur"));

            var select = new SelectField(Selenium.Object, _form, Id.Is("select"));

            select.Blur();
        }
        private SelectField FieldFor(string tableName, string columnName, string alias = null)
        {
            var result = new SelectField(tableName, columnName);

            if (alias != null)
            {
                result.SetAlias(alias);
            }
            return(result);
        }
        public void TestChooseWithExpectedIndexValue()
        {
            Selenium.Setup(
                o => o.Select(FormXpath + "/select[@id='select']", "Element"));

            Selenium.Setup(
                o => o.GetSelectOptions(FormXpath + "/select[@id='select']"))
                .Returns(new[] {"", "", "Element"});

            var select = new SelectField(Selenium.Object, _form, Id.Is("select"));

            select.Choose(2);
        }
示例#9
0
        public static string GetTotalNum(SelectField selectfield)
        {
            SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@TableName", SqlDbType.VarChar, 100), new SqlParameter("@Field", SqlDbType.VarChar, 100), new SqlParameter("@NewField", SqlDbType.VarChar, 100), new SqlParameter("@Condition", SqlDbType.VarChar, 0x1f40) };
            pars[0].Value = selectfield.TableName;
            pars[1].Value = selectfield.Field;
            pars[2].Value = selectfield.NewField;
            pars[3].Value = selectfield.Condition;
            DataSet allInfo = SqlHelper.GetAllInfo(pars, "getTotalNum");

            if ((allInfo != null) && (allInfo.Tables[0].Rows.Count != 0))
            {
                return(allInfo.Tables[0].Rows[0][0].ToString());
            }
            return("0");
        }
        private void buttonMoveDown_Click(object sender, RoutedEventArgs e)
        {
            List <int> selectedIndices = GetSelectedInidices();

            for (int i = 0; i < selectedIndices.Count; i++)
            {
                if (selectedIndices[i] < fullList.Count - 1)
                {
                    int         index   = selectedIndices[i];
                    SelectField lvField = fullList[index];
                    fullList.Remove(lvField);
                    fullList.Insert(index + 1, lvField);
                    DataGridFields.SelectedItems.Add(lvField);
                }
            }
        }
示例#11
0
        /// <summary>
        /// pb 自定义表单定义的帮助
        /// </summary>
        /// <param name="pbCtl"></param>
        /// <returns></returns>
        public static BaseField GetCustomHelp(PbBaseControlInfo pbCtl)
        {
            PbDataHelpEditInfo pbDataHelp = (PbDataHelpEditInfo)pbCtl;
            BaseField          baseField  = null;

            DataTable dt = SUP.CustomForm.DataAccess.Common.GetHelpInfo(pbDataHelp.DataHelpId);

            //这时候需要去数据库查 helpid
            if (dt != null)
            {
                if (dt.Rows[0]["fromsql"].Equals("1"))  //弹出帮助类型的
                {
                    CustomHelpField ngCustomFormHelp = new CustomHelpField();

                    ngCustomFormHelp.ID         = pbDataHelp.Id;
                    ngCustomFormHelp.Name       = pbDataHelp.Name;
                    ngCustomFormHelp.FieldLabel = pbDataHelp.LeftText;
                    ngCustomFormHelp.MustInput  = pbDataHelp.IsMustInput;
                    ngCustomFormHelp.XType      = "ngCustomHelp";
                    ngCustomFormHelp.HelpID     = pbDataHelp.DataHelpId;

                    baseField = ngCustomFormHelp;

                    //ngCustomFormHelp.ListHeadTexts = dt.Rows[0]["datetitle"].ToString() + "," +
                    //                             dt.Rows[0]["viewtitle"].ToString();
                    //ngCustomFormHelp.ValueField = dt.Rows[0]["col_data"].ToString();
                    //ngCustomFormHelp.DisplayField = dt.Rows[0]["col_view"].ToString();
                    //ngCustomFormHelp.ListFields = dt.Rows[0]["col_data"].ToString() + "," +
                    //                          dt.Rows[0]["col_view"].ToString();
                }
                else
                {  //下拉式两列的帮助
                    SelectField select = new SelectField();
                    select.XType = "ngSelect";

                    foreach (DataRow info in dt.Rows)
                    {
                        select.Options.Add(string.Format(@"text:'{0}',value:'{1}'",
                                                         info["base_code"].ToString(), info["base_name"].ToString()));
                    }

                    baseField = select;
                }
            }

            return(baseField);
        }
示例#12
0
        private static BaseField GetSelect(PbBaseControlInfo pbCtl)
        {
            PbComboboxInfo pbComb   = (PbComboboxInfo)pbCtl;
            SelectField    ngSelect = new SelectField();

            ngSelect.ID         = pbComb.Id;
            ngSelect.Name       = pbComb.Name;
            ngSelect.FieldLabel = pbComb.LeftText;
            ngSelect.MustInput  = pbComb.IsMustInput;
            ngSelect.XType      = "ngSelect";


            foreach (var info in pbComb.PbComboboxValueInfos)
            {
                ngSelect.Options.Add(string.Format(@"text:'{0}',value:'{1}'",
                                                   info.SaveValue, info.DisplayValue));
            }

            return(ngSelect);
        }
        public override object ReadJson(JsonReader reader,
                                        Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var jsonObject = JObject.Load(reader);
            var field      = default(IIntegrationSetupField);
            var fieldToken = jsonObject["FieldType"];

            if (fieldToken is null)
            {
                fieldToken = jsonObject["fieldType"];
            }
            switch (fieldToken.ToString())
            {
            case nameof(CheckboxField):
                field = new CheckboxField();
                break;

            case nameof(ShortTextField):
                field = new ShortTextField();
                break;

            case nameof(LongTextField):
                field = new LongTextField();
                break;

            case nameof(SsmlField):
                field = new SsmlField();
                break;

            case nameof(SelectField):
                field = new SelectField();
                break;

            case nameof(SwitchField):
                field = new SwitchField();
                break;
            }
            serializer.Populate(jsonObject.CreateReader(), field);
            return(field);
        }
        public static string ChangeOrderStatus(string storeId, string orderId)
        {
            Order order = TC.GetOrder(Convert.ToInt32(storeId), new Guid(orderId));
            Store store = TC.GetStore(Convert.ToInt32(storeId));

            Form orderForm = new Form();
            FormFieldset statusFieldset = new FormFieldset();
            orderForm.AddFieldset(statusFieldset);

            SelectField status = new SelectField("status", "Status", order.OrderStatusId.ToString());

            foreach (KeyValuePair<int, OrderStatus> orderStatus in TCExtensions.GetOrderStatuses()) {
                status.AddOption(orderStatus.Value.Name, orderStatus.Key.ToString());
            }

            statusFieldset.AddFormItem(status);

            orderForm.primary = new Button("Save", new Call("OrderSave", new string[] { order.StoreId.ToString(), order.Id.ToString() }));

            return orderForm.UmGo(order.OrderNumber);
        }
示例#15
0
        public ShipsMappingForm(SelectField FieldCallBack)
        {
            InitializeComponent();
            ConfirmField = FieldCallBack;
            field        = new Field(10);
            FieldView    = new FieldViewer(10, new System.Drawing.Point(458, 1), 50);
            FieldView.CellContentClick += CellClickHandler;
            FieldView.Enabled           = false;
            CurCounters = new int[4];

            for (int i = 0; i < 4; ++i)
            {
                CurCounters[i] = i + 1;
            }
            this.Controls.Add(FieldView);
            FieldView.Enabled      = false;
            ResetShipBtn.Enabled   = false;
            ConfirmShipBtn.Enabled = false;
            deleteMode             = false;
            //deleteship too
        }
示例#16
0
        public override void Build(ParsedSql ret, List <string> tokens, ref int i)
        {
            SelectStatement selectStatement = new SelectStatement();

            ret.Select = selectStatement;
            i++;

            var from = new From();

            while (i < tokens.Count)
            {
                if (from.MatchParser(tokens[i]))
                {
                }
                else
                {
                    var sf = new SelectField();
                    sf.Name = tokens[i++];
                    selectStatement.Fields.Add(sf);
                }
            }
        }
示例#17
0
        /// <summary>
        /// 組合Group By所需條件
        /// </summary>
        /// <param name="GroupByProcess">判斷是否作Group By</param>
        /// <param name="SelectFieldList">將查詢欄位帶入</param>
        /// <returns>回傳Group By所需SQL</returns>
        private static string GetGroupByProcess(bool GroupByProcess,
                                                SelectField[] SelectFieldList
                                                )
        { 
            StringBuilder sb = new StringBuilder();
            int StrCounter = 0;

            if (GroupByProcess)
            {
                if (SelectFieldList.Length >0)
                {
                    sb.Append("Group By ");
                }

                for (int i = 0; i < SelectFieldList.Length; i++)
                {
                    //如果是一般欄位
                    if (SelectFieldList[i].FieldType == SelectFiledType.NormalField)
                    {
                        if (StrCounter == 0)
                        {
                            sb.AppendFormat("{0}", SelectFieldList[i].FieldName);
                        }
                        else
                        {
                            sb.AppendFormat(",{0}", SelectFieldList[i].FieldName);
                        }

                        StrCounter++;
                    }

                    //如果是最後
                    if (i == SelectFieldList.Length - 1)
                    {
                        sb.Append(" ");
                    }
                }

            }

            return sb.ToString();
        }
示例#18
0
        /// <summary>
        /// Binds the attendees grid.
        /// </summary>
        private void BindGiversGrid()
        {
            // Get all the selected criteria values
            var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(drpSlidingDateRange.DelimitedValues);
            var start     = dateRange.Start;
            var end       = dateRange.End;

            var minAmount = nreAmount.LowerValue;
            var maxAmount = nreAmount.UpperValue;

            var currencyTypeIds = new List <int>();

            cblCurrencyTypes.SelectedValues.ForEach(i => currencyTypeIds.Add(i.AsInteger()));

            var sourceTypeIds = new List <int>();

            cblTransactionSource.SelectedValues.ForEach(i => sourceTypeIds.Add(i.AsInteger()));

            var accountIds = new List <int>();

            foreach (var cblAccounts in phAccounts.Controls.OfType <RockCheckBoxList>())
            {
                accountIds.AddRange(cblAccounts.SelectedValuesAsInt);
            }

            var dataViewId = dvpDataView.SelectedValueAsInt();

            GiversViewBy viewBy = GiversViewBy.Giver;

            if (!HideViewByOption)
            {
                viewBy = hfViewBy.Value.ConvertToEnumOrNull <GiversViewBy>() ?? GiversViewBy.Giver;
            }

            // Clear all the existing grid columns
            var selectField    = new SelectField();
            var oldSelectField = gGiversGifts.ColumnsOfType <SelectField>().FirstOrDefault();

            if (oldSelectField != null)
            {
                selectField.SelectedKeys.AddRange(oldSelectField.SelectedKeys);
            }

            gGiversGifts.Columns.Clear();

            // Add a column for selecting rows
            gGiversGifts.Columns.Add(selectField);

            // Add a column for the person's name
            gGiversGifts.Columns.Add(
                new RockBoundField
            {
                DataField      = "PersonName",
                HeaderText     = "Person",
                SortExpression = "LastName,NickName"
            });

            // add a column for email (but is only included on excel export)
            gGiversGifts.Columns.Add(
                new RockBoundField
            {
                DataField           = "Email",
                HeaderText          = "Email",
                SortExpression      = "Email",
                Visible             = false,
                ExcelExportBehavior = ExcelExportBehavior.AlwaysInclude
            });

            // Add a column for total amount
            gGiversGifts.Columns.Add(
                new CurrencyField
            {
                DataField      = "TotalAmount",
                HeaderText     = "Total",
                SortExpression = "TotalAmount"
            });


            // Add columns for the selected account totals
            if (accountIds.Any())
            {
                var accounts = new FinancialAccountService(_rockContext)
                               .Queryable().AsNoTracking()
                               .Where(a => accountIds.Contains(a.Id))
                               .ToList();

                foreach (int accountId in accountIds)
                {
                    var account = accounts.FirstOrDefault(a => a.Id == accountId);
                    if (account != null)
                    {
                        gGiversGifts.Columns.Add(
                            new CurrencyField
                        {
                            DataField      = account.Id.ToString(),
                            HeaderText     = account.Name,
                            SortExpression = account.Id.ToString()
                        });
                    }
                }
            }

            // Add a column for the number of gifts
            var numberGiftsField = new RockBoundField
            {
                DataField        = "NumberGifts",
                HeaderText       = "Number of Gifts",
                SortExpression   = "NumberGifts",
                DataFormatString = "{0:N0}",
            };

            numberGiftsField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
            gGiversGifts.Columns.Add(numberGiftsField);

            // Add a column to indicate if this is a first time giver
            gGiversGifts.Columns.Add(
                new BoolField
            {
                DataField      = "IsFirstEverGift",
                HeaderText     = "Is First Gift",
                SortExpression = "IsFirstEverGift"
            });

            // Add a column for the first gift date ( that matches criteria )
            gGiversGifts.Columns.Add(
                new DateField
            {
                DataField      = "FirstGift",
                HeaderText     = "First Gift",
                SortExpression = "FirstGift"
            });

            // Add a column for the first-ever gift date ( to any tax-deductible account )
            gGiversGifts.Columns.Add(
                new DateField
            {
                DataField      = "FirstEverGift",
                HeaderText     = "First Gift Ever",
                SortExpression = "FirstEverGift"
            });


            var transactionDetailService = new FinancialTransactionDetailService(_rockContext);
            var personService            = new PersonService(_rockContext);

            // If dataview was selected get the person id's returned by the dataview
            var dataViewPersonIds = new List <int>();

            if (dataViewId.HasValue)
            {
                var dataView = new DataViewService(_rockContext).Get(dataViewId.Value);
                if (dataView != null)
                {
                    var errorMessages = new List <string>();
                    ParameterExpression paramExpression = personService.ParameterExpression;
                    Expression          whereExpression = dataView.GetExpression(personService, paramExpression, out errorMessages);

                    SortProperty sortProperty        = null;
                    var          dataViewPersonIdQry = personService
                                                       .Queryable().AsNoTracking()
                                                       .Where(paramExpression, whereExpression, sortProperty)
                                                       .Select(p => p.Id);
                    dataViewPersonIds = dataViewPersonIdQry.ToList();
                }
            }

            // Check to see if grid should display only people who gave a certain number of times and if so
            // set the min value
            int minCount          = 0;
            var previousPersonIds = new List <int>();

            if (radByPattern.Checked)
            {
                minCount = tbPatternXTimes.Text.AsInteger();
                var missedStart = drpPatternDateRange.LowerValue;
                var missedEnd   = drpPatternDateRange.UpperValue;
                if (missedStart.HasValue && missedEnd.HasValue)
                {
                    // Get the givingids that gave any amount during the pattern's date range. These
                    // are needed so that we know who to exclude from the result set
                    var previousGivingIds = transactionDetailService
                                            .Queryable().AsNoTracking()
                                            .Where(d =>
                                                   d.Transaction.TransactionDateTime.HasValue &&
                                                   d.Transaction.TransactionDateTime.Value >= missedStart.Value &&
                                                   d.Transaction.TransactionDateTime.Value < missedEnd.Value &&
                                                   accountIds.Contains(d.AccountId) &&
                                                   d.Amount != 0.0M)
                                            .Select(d => d.Transaction.AuthorizedPersonAlias.Person.GivingId);

                    // Now get the person ids from the givingids
                    previousPersonIds = personService
                                        .Queryable().AsNoTracking()
                                        .Where(p => previousGivingIds.Contains(p.GivingId))
                                        .Select(p => p.Id)
                                        .ToList();
                }
            }

            // Call the stored procedure to get all the giving data that matches the selected criteria.
            // The stored procedure returns two tables. First is a list of all matching transaction summary
            // information and the second table is each giving leader's first-ever gift date to a tax-deductible account
            DataSet ds = FinancialTransactionDetailService.GetGivingAnalytics(start, end, minAmount, maxAmount,
                                                                              accountIds, currencyTypeIds, sourceTypeIds, dataViewId, viewBy);

            // Get the results table
            DataTable dtResults = ds.Tables[0];

            // Get the first-ever gift dates and load them into a dictionary for faster matching
            DataTable dtFirstEver   = ds.Tables[1];
            var       firstEverVals = new Dictionary <int, DateTime>();

            foreach (DataRow row in ds.Tables[1].Rows)
            {
                if (!DBNull.Value.Equals(row["FirstEverGift"]))
                {
                    firstEverVals.Add((int)row["PersonId"], (DateTime)row["FirstEverGift"]);
                }
            }

            // Add columns to the result set for the first-ever data
            dtResults.Columns.Add(new DataColumn("IsFirstEverGift", typeof(bool)));
            dtResults.Columns.Add(new DataColumn("FirstEverGift", typeof(DateTime)));

            foreach (DataRow row in dtResults.Rows)
            {
                bool rowValid = true;

                // Get the person id
                int personId = (int)row["Id"];

                if (radByPattern.Checked)
                {
                    // If pattern was specified check minimum gifts and other date range
                    int numberGifts = (int)row["NumberGifts"];
                    if (numberGifts < minCount)
                    {
                        rowValid = false;
                    }
                    else
                    {
                        // If this giving leader gave during the pattern date, remove the row since we
                        // only want those who did not
                        if (previousPersonIds.Contains(personId))
                        {
                            rowValid = false;
                        }
                    }
                }

                if (dataViewId.HasValue)
                {
                    // If a dataview filter was specified, and this row is not part of dataview,
                    // remove it
                    if (!dataViewPersonIds.Contains(personId))
                    {
                        rowValid = false;

                        // Remove person id from list so that list can be used later to optionally
                        // add rows for remaining people who were in the dataview, but not in the
                        // result set
                        dataViewPersonIds.Remove(personId);
                    }
                }

                if (rowValid)
                {
                    // Set the first ever information for each row
                    bool     isFirstEverGift = false;
                    DateTime firstGift       = (DateTime)row["FirstGift"];
                    if (firstEverVals.ContainsKey(personId))
                    {
                        DateTime firstEverGift = firstEverVals[personId];
                        isFirstEverGift = firstEverGift.Equals(firstGift);

                        row["FirstEverGift"] = firstEverGift;
                    }

                    // If only first time givers should be included, remove any that are not
                    if (radFirstTime.Checked && !isFirstEverGift)
                    {
                        rowValid = false;
                    }
                    else
                    {
                        row["IsFirstEverGift"] = isFirstEverGift;
                    }
                }

                if (!rowValid)
                {
                    row.Delete();
                }
            }

            // if dataview was selected and it includes people not in the result set,
            if (dataViewId.HasValue && rblDataViewAction.SelectedValue == "All" && dataViewPersonIds.Any())
            {
                // Query for the names of each of these people
                foreach (var person in personService
                         .Queryable().AsNoTracking()
                         .Select(p => new {
                    p.Id,
                    p.Guid,
                    p.NickName,
                    p.LastName,
                    p.Email
                }))
                {
                    // Check for a first ever gift date
                    var firstEverGiftDate = firstEverVals
                                            .Where(f => f.Key == person.Id)
                                            .Select(f => f.Value)
                                            .FirstOrDefault();

                    DataRow row = dtResults.NewRow();
                    row["Id"]              = person.Id;
                    row["Guid"]            = person.Guid;
                    row["NickName"]        = person.NickName;
                    row["LastName"]        = person.LastName;
                    row["PersonName"]      = person.NickName + " " + person.LastName;
                    row["Email"]           = person.Email;
                    row["IsFirstEverGift"] = false;
                    row["FirstEverGift"]   = firstEverGiftDate;
                    dtResults.Rows.Add(row);
                }
            }

            // Update the changes (deletes) in the datatable
            dtResults.AcceptChanges();

            // Calculate Total
            if (viewBy == GiversViewBy.Giver)
            {
                pnlTotal.Visible = true;
                object amountTotalObj = dtResults.Compute("Sum(TotalAmount)", null);
                if (amountTotalObj != null)
                {
                    decimal amountTotal = amountTotalObj.ToString().AsDecimal();
                    lTotal.Text = amountTotal.FormatAsCurrency();
                }
                else
                {
                    lTotal.Text = string.Empty;
                }
            }
            else
            {
                pnlTotal.Visible = false;
            }

            // Sort the results
            System.Data.DataView dv = dtResults.DefaultView;
            if (gGiversGifts.SortProperty != null)
            {
                try
                {
                    var sortProperties = new List <string>();
                    foreach (string prop in gGiversGifts.SortProperty.Property.SplitDelimitedValues(false))
                    {
                        sortProperties.Add(string.Format("[{0}] {1}", prop, gGiversGifts.SortProperty.DirectionString));
                    }
                    dv.Sort = sortProperties.AsDelimited(", ");
                }
                catch
                {
                    dv.Sort = "[LastName] ASC, [NickName] ASC";
                }
            }
            else
            {
                dv.Sort = "[LastName] ASC, [NickName] ASC";
            }

            gGiversGifts.DataSource = dv;
            gGiversGifts.DataBind();
        }
示例#19
0
        internal static BaseField CreateField(FieldType type)
        {
            BaseField field = null;

            switch (type)
            {
            case FieldType.ObjectKey:
                field = new ObjectKeyField();
                break;

            case FieldType.BigInt:
                field = new BigIntField();
                break;

            case FieldType.Bool:
                field = new BoolField();
                break;

            case FieldType.Date:
                field = new DateField();
                break;

            case FieldType.DateTime:
                field = new DateTimeField();
                break;

            case FieldType.Decimal:
                field = new DecimalField();
                break;

            case FieldType.Image:
                field = new ImageField();
                break;

            case FieldType.Integer:
                field = new IntegerField();
                break;

            case FieldType.LongText:
                field = new LongTextField();
                break;

            case FieldType.Password:
                field = new PasswordField();
                break;

            case FieldType.MonataryAmount:
                field = new DecimalField();
                break;

            case FieldType.Html:
                field = new HtmlField();
                break;

            case FieldType.Xml:
                field = new XmlField();
                break;

            case FieldType.Json:
                field = new JsonField();
                break;

            case FieldType.Email:
                field = new EmailField();
                break;

            case FieldType.Phone:
                field = new PhoneField();
                break;

            case FieldType.ObjectLink:
                field = new ObjectLinkField();
                break;

            case FieldType.MultiObjectLink:
                field = new MultiObjectLinkField();
                break;

            case FieldType.Select:
                field = new SelectField();
                break;

            case FieldType.MultiSelect:
                field = new MultiSelectField();
                break;

            case FieldType.FilterField:
                field = new FilterField();
                break;

            case FieldType.OneToMany:
                field = new OneToManyField();
                break;

            default:
                field = new StringField();
                break;
            }
            return(field);
        }
示例#20
0
 public static string GetTotalNum(SelectField selectfield)
 {
     return(DAL.SelectByPager.GetTotalNum(selectfield));
 }
示例#21
0
        public IEnumerable <Document> MoreLikeThis(MoreLikeThisQueryServerSide query, HashSet <string> stopWords, Func <SelectField[], IQueryResultRetriever> createRetriever, JsonOperationContext documentsContext, Func <string, SpatialField> getSpatialField, CancellationToken token)
        {
            var documentQuery = new BooleanQuery();

            if (string.IsNullOrWhiteSpace(query.DocumentId) == false)
            {
                documentQuery.Add(new TermQuery(new Term(Constants.Documents.Indexing.Fields.DocumentIdFieldName, query.DocumentId.ToLowerInvariant())), Occur.MUST);
            }

            foreach (var key in query.MapGroupFields.Keys)
            {
                documentQuery.Add(new TermQuery(new Term(key, query.MapGroupFields[key])), Occur.MUST);
            }

            var td = _searcher.Search(documentQuery, 1, _state);

            // get the current Lucene docid for the given RavenDB doc ID
            if (td.ScoreDocs.Length == 0)
            {
                throw new InvalidOperationException("Document " + query.DocumentId + " could not be found");
            }

            var ir  = _searcher.IndexReader;
            var mlt = new RavenMoreLikeThis(ir, query, _state);

            if (stopWords != null)
            {
                mlt.SetStopWords(stopWords);
            }

            string[] fieldNames;
            if (query.Fields != null && query.Fields.Length > 0)
            {
                fieldNames = query.Fields;
            }
            else
            {
                fieldNames = ir.GetFieldNames(IndexReader.FieldOption.INDEXED)
                             .Where(x => x != Constants.Documents.Indexing.Fields.DocumentIdFieldName && x != Constants.Documents.Indexing.Fields.ReduceKeyHashFieldName)
                             .ToArray();
            }

            mlt.SetFieldNames(fieldNames);
            mlt.Analyzer = _analyzer;

            var pageSize = GetPageSize(_searcher, query.PageSize);
            var mltQuery = mlt.Like(td.ScoreDocs[0].Doc);
            var tsdc     = TopScoreDocCollector.Create(pageSize, true);

            if (query.Metadata.WhereFields.Count > 0)
            {
                var additionalQuery = QueryBuilder.BuildQuery(documentsContext, query.Metadata, query.Metadata.Query.Where, null, _analyzer, getSpatialField);
                mltQuery = new BooleanQuery
                {
                    { mltQuery, Occur.MUST },
                    { additionalQuery, Occur.MUST }
                };
            }

            _searcher.Search(mltQuery, tsdc, _state);
            var hits      = tsdc.TopDocs().ScoreDocs;
            var baseDocId = td.ScoreDocs[0].Doc;

            var ids = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            var fieldsToFetch = string.IsNullOrWhiteSpace(query.DocumentId)
                ? _searcher.Doc(baseDocId, _state).GetFields().Cast <AbstractField>().Select(x => x.Name).Distinct().Select(x => SelectField.Create(x)).ToArray()
                : null;

            var retriever = createRetriever(fieldsToFetch);

            foreach (var hit in hits)
            {
                if (hit.Doc == baseDocId)
                {
                    continue;
                }

                var doc = _searcher.Doc(hit.Doc, _state);
                var id  = doc.Get(Constants.Documents.Indexing.Fields.DocumentIdFieldName, _state) ?? doc.Get(Constants.Documents.Indexing.Fields.ReduceKeyHashFieldName, _state);
                if (id == null)
                {
                    continue;
                }

                if (ids.Add(id) == false)
                {
                    continue;
                }

                yield return(retriever.Get(doc, hit.Score, _state));
            }
        }
示例#22
0
        public void Values()
        {
            Selenium.Setup(
                o => o.GetSelectOptions(FormXpath + "/select[@id='select']"));

            var select = new SelectField(Selenium.Object, _form, Id.Is("select"));

            select.Values();
        }
示例#23
0
		void Paint(Element parent)
		{	
			new Div(parent, div=>{
				div.ClassName="span6 offset3 well";
				div.Hide();
			}) ;
			
			SearchDiv= new Div(default(Element), searchdiv=>{
				searchdiv.ClassName= "span6 offset3 nav";

				var inputFecha=new InputText(searchdiv, ip=>{
					ip.ClassName="input-medium search-query";
					ip.SetAttribute("data-mask","99.99.9999");
					ip.SetPlaceHolder("dd.mm.aaaa");
				}).Element(); 
				
				new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-search icon-large";
					abn.JSelect().Click(evt=>{
						if( ! inputFecha.Value.IsDateFormatted()){
							Div.CreateAlertErrorAfter(SearchDiv.Element(),"Digite una fecha valida");
							return;
						}
						LoadGastos( inputFecha.Value.ToServerDate() );

					});
				});

				BNew= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-plus-sign icon-large";
					abn.JSelect().Click(evt=>{
						FormDiv.FadeIn();
						GridDiv.FadeOut();
						Form.Element().Reset();
						BDelete.Element().Disabled=true;
					});
				});

				BDelete=new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-remove-sign icon-large";
					abn.Disabled=true;
					abn.JSelect().Click(evt=>{
						RemoveRow();
					});
				});

				BList= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-reorder icon-large";
					abn.Disabled=true;
					abn.JSelect().Click(evt=>{
						FormDiv.FadeOut();
						GridDiv.FadeIn();
						abn.Disabled=true;
					});
				});
				
			});
			SearchDiv.AppendTo(parent);
			
			
			FormDiv= new Div(default(Element), formdiv=>{
				formdiv.ClassName="span6 offset3 well";
				Form = new Form(formdiv, f=>{
					f.ClassName="form-horizontal";
					f.Action="api/Gasto/";
					f.Method="post";

					var inputId= new InputText(f, e=>{
						e.Name="Id";
						e.Hide();
					}); 

					var cbConcepto=new SelectField(f, (e)=>{
						e.Name="IdConcepto";
						e.ClassName="span12";
						new HtmlOption(e, o=>{
							o.Value="";
							o.Selected=true;
							o.Text="Seleccione el concepto ...";
						});											
						LoadConceptos(e);
					});
					
					var cbFuente= new SelectField(f, (e)=>{
						e.Name="IdFuente";
						e.ClassName="span12";
						new HtmlOption(e, o=>{
							o.Value="";
							o.Selected=true;
							o.Text="Seleccione la fuente de pago ...";
						});											
						LoadFuentes(e);
					});
					
					var fieldValor= new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Valor";
						field.SetPlaceHolder("$$$$$$$$$$");
						field.AutoNumericInit();
						field.Style.TextAlign="right";
					});
					
					new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Beneficiario";
						field.SetPlaceHolder("Pagado a ....");
					});
					
					new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Descripcion";
						field.SetPlaceHolder("Descripcion");
					});
										
					var bt = new SubmitButton(f, b=>{
						b.JSelect().Text("Guardar");
						b.LoadingText(" Guardando ...");
						b.ClassName="btn btn-info btn-block" ;
					});
					
					var vo = new ValidateOptions()
						.SetSubmitHandler( form=>{
							
							bt.ShowLoadingText();

							var action= form.Action+(string.IsNullOrEmpty(inputId.Value())?"create":"update");
							jQuery.PostRequest<BLResponse<Gasto>>(action, form.AutoNumericGetString(), cb=>{},"json")
								.Success(d=>{
									Cayita.Javascript.Firebug.Console.Log("Success guardar gasto",d);
									if(string.IsNullOrEmpty(inputId.Value()) )
										AppendRow(d.Result[0]);
									else
										UpdateRow(d.Result[0]);

									form.Reset();
								})
									.Error((request,  textStatus,  error)=>{
										Cayita.Javascript.Firebug.Console.Log("request", request );
										Cayita.Javascript.Firebug.Console.Log("error", error );
										Div.CreateAlertErrorBefore(form.Elements[0],
										                           textStatus+": "+ request.StatusText);
									})
									.Always(a=>{
										bt.ResetLoadingText();
									});
							
						})
							.AddRule((rule, msg)=>{
								rule.Element=fieldValor.Element();
								rule.Rule.Required();
								msg.Required("Digite el valor del gasto");
							})

							.AddRule((rule, msg)=>{
								rule.Element=cbConcepto.Element();
								rule.Rule.Required();
								msg.Required("Seleccione el concepto");
							})
							
							.AddRule((rule, msg)=>{
								rule.Element=cbFuente.Element();
								rule.Rule.Required();
								msg.Required("Seleccione al fuente del pago");
							});
					
					f.Validate(vo);				
				});
			});

			FormDiv.AppendTo(parent);
						
			GridDiv= new  Div(default(Element), gdiv=>{
				gdiv.ClassName="span10 offset1";

				TableGastos= new HtmlTable(gdiv, table=>{
					InitTable (table);
				});	
				gdiv.Hide();
			});

			GridDiv.AppendTo(parent);	
		}
示例#24
0
        public void Select(string tableName)
        {
            var selectionString = $"{Adapter.Table(tableName)}.*";

            SelectField.Add(selectionString);
        }
示例#25
0
 public void Select(string tableName, string fieldName)
 {
     SelectField.Add(Adapter.Field(tableName, fieldName));
 }
示例#26
0
 private static void ThrowInvalidFieldInFacetQuery(FacetQuery query, SelectField field)
 {
     throw new InvalidQueryException(
               $"It encountered a field in SELECT clause which is not a facet. Field: {field.Name}", query.Query.Metadata.QueryText,
               query.Query.QueryParameters);
 }
示例#27
0
        protected IStorageSelectField CreateEmptySelectFieldObject(SelectField field)
        {
            var storageService = service.StorageService;

            return((IStorageSelectField)storageService.GetObjectFactory().CreateEmptyFieldObject(field.GetType()));
        }
示例#28
0
 public void Visit(SelectField component)
 {
     throw new NotImplementedException();
 }
示例#29
0
        private bool AddBatchScriptItem([NotNull] Query query, [NotNull] SelectDataTable dataTable, [NotNull] Item item, int count)
        {
            Debug.ArgumentNotNull(dataTable, nameof(dataTable));
            Debug.ArgumentNotNull(item, nameof(item));

            var result = true;

            var selectItem = new SelectItem
            {
                Item = item
            };

            var columnIndex = 0;

            foreach (var columnExpression in ColumnExpressions)
            {
                var selectField = new SelectField();

                if (columnExpression.FieldName != null)
                {
                    selectField.Value = item[columnExpression.FieldName];
                    selectField.Field = item.Fields[columnExpression.FieldName];
                }
                else if (columnExpression.Expression != null)
                {
                    var value = query.EvaluateSubQuery(columnExpression.Expression, item);

                    if (value != null)
                    {
                        selectField.Value = value.ToString();
                    }
                    else
                    {
                        var function = columnExpression.Expression as Function;
                        if (function != null && string.Compare(function.Name, "count", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            selectField.Value = count.ToString();
                            result            = false;
                        }
                        else
                        {
                            selectField.Value = "<null>";
                        }
                    }
                }

                var columnName = columnExpression.ColumnName;
                if (string.IsNullOrEmpty(columnName))
                {
                    columnName = "Column " + columnIndex;
                    columnIndex++;
                }

                selectField.ColumnName = columnName;

                selectItem.Fields.Add(selectField);
            }

            dataTable.Items.Add(selectItem);

            return(result);
        }
示例#30
0
		protected IStorageSelectField CreateEmptySelectFieldObject(SelectField field)
		{
			var storageService = service.StorageService;
			return (IStorageSelectField)storageService.GetObjectFactory().CreateEmptyFieldObject(field.GetType());
		}
示例#31
0
        /// <summary>
        /// 組合選取欄位
        /// </summary>
        /// <param name="SelectFieldList">選取欄位資料</param>
        /// <returns>回傳選取欄位</returns>
        private static string GetSelectField(SelectField[] SelectFieldList)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < SelectFieldList.Length; i++)
            {
                if (i != SelectFieldList.Length - 1)
                {                    
                    sb.AppendFormat("{0},", SelectFieldList[i].FieldName);
                }
                else
                {
                    sb.AppendFormat("{0} ", SelectFieldList[i].FieldName);
                }
            }

            return sb.ToString();
        }
示例#32
0
 public static int GetCount(SelectField selectfield)
 {
     return(DAL.SelectByPager.GetCount(selectfield));
 }
        private void FillList()
        {
            fullList.Clear();

            if (currentFields != null)
            {
                foreach (ColumnField field in currentFields)
                {
                    SelectField sf = new SelectField();
                    if (fieldType == DataBaseEngine.FieldType.TrackAndCD)
                    {
                        sf.Name = dataBase.GetNameOfFieldFull(field.Field);
                    }
                    else
                    {
                        sf.Name = dataBase.GetNameOfField(field.Field);
                    }
                    sf.Field         = field.Field;
                    sf.Width         = field.Width;
                    sf.TextAlignment = field.TextAlignment;
                    sf.IsChecked     = true;
                    fullList.Add(sf);
                }
            }

            foreach (Field field in FieldHelper.GetAllFields())
            {
                if (field != Field.None && currentFields.FirstOrDefault(x => x.Field == field) == null && !FieldHelper.IsInternalField(field))
                {
                    string name = null;

                    switch (fieldType)
                    {
                    case FieldType.CD:
                        if (FieldHelper.IsCDField(field))
                        {
                            name = dataBase.GetNameOfField(field);
                        }
                        break;

                    case FieldType.Track:
                        if (FieldHelper.IsTrackField(field))
                        {
                            name = dataBase.GetNameOfField(field);
                        }
                        break;

                    case FieldType.TrackMain:
                        if (FieldHelper.IsTrackField(field, true))
                        {
                            name = dataBase.GetNameOfField(field);
                        }
                        break;

                    default:
                        name = dataBase.GetNameOfFieldFull(field);
                        break;
                    }

                    if (name != null)
                    {
                        SelectField sf = new SelectField();
                        sf.Width     = dataBase.GetDefaultColumnWidthOfField(field);
                        sf.Name      = name;
                        sf.Field     = field;
                        sf.IsChecked = false;
                        fullList.Add(sf);
                    }
                }
            }

            DataGridFields.ItemsSource = fullList;
        }
        public void ExampleOf_BuildingQueryWithDynamicColumnName()
        {
            //--------------- Arrange -------------------
            const string CONT  = "Contract";
            const string LUTCC = "tblLUTCellCaptive";
            const string POL   = "policy";
            const string POLT  = "tblLUTPolicyType";
            const string PR    = "tblPolicyRole";
            const string CL    = "tblClient";
            const string C     = "Claim";
            const string TPOL  = "tblPolicy";
            const string TA    = "tblAsset";
            const string TD    = "tblDealer";
            const string PT    = "ProductType";

            var sqlQuery = @"SELECT CONT.fCertificate as PolicyNumber," +
                           "CONT.fAccName as AccountName," +
                           "CL.fFirstName+''+CL.fSurname as CellCaptive," +
                           "PT.Description as ProductName," +
                           "CONT.fTransactionNo as TransactionNumber," +
                           "TD.fName as Dealer," +
                           "TPOL.fWebPolicyID as WebPolicyId " +
                           " FROM Contract (NOLOCK) CONT " +
                           " JOIN tblLUTCellCaptive(NOLOCK)LUTCC ON LUTCC.fCellCaptiveID = CONT.fCellCaptiveID" +
                           " JOIN policy (NOLOCK) POL ON POL.ContractIntID = CONT.ContractIntID" +
                           " JOIN tblLUTPolicyType POLT (NOLOCK) ON POLT.fPolicyTypeID = POL.PolicyTypeID" +
                           " JOIN tblPolicyRole PR(NOLOCK) ON PR.fPolicyID = POL.PolicyIntID " +
                           " JOIN tblClient CL(NOLOCK) ON CL.fClientID = PR.fClientID" +
                           " JOIN Claim C(NOLOCK) ON C.PolicyID = POL.PolicyID" +
                           " JOIN tblPolicy TPOL(NOLOCK) ON TPOL.fPolicyID = PR.fPolicyID" +
                           " JOIN tblAsset TA(NOLOCK) on TA.fAssetID = TPOL.fAssetID" +
                           " JOIN tblDealer(NOLOCK) TD ON TD.fDealerID = TPOL.fDealerID " +
                           " JOIN ProductType (NOLOCK)  PT on PT.ProductTypeID = POLT.ProductTypeID " +
                           " WHERE @option like '%'+ @searchTerm +'%' ";
            var searchOption = new SelectField(CONT, "fCertificate");

            var searchTerm = "MKWM000819";
            var replaced   = sqlQuery.Replace("@option", searchOption.ToString()).Replace("@searchTerm", searchTerm);

            //--------------- Assume ----------------

            //--------------- Act ----------------------
            var sql = SelectStatementBuilder.Create()
                      .WithDatabaseProvider(DatabaseProviders.SQLServer)
                      .WithNoLock()
                      .WithField(FieldFor(CONT, "fAccName", "AccountName"))
                      .WithField(new ConcatenatedField(
                                     "CellCaptive",
                                     FieldFor(CL, "fFirstName"),
                                     FieldFor(CL, "fSurname")))
                      .WithField(FieldFor(PT, "Description", "ProductName"))
                      .WithField(FieldFor(CONT, "fTransactionNo", "TransactionNumber"))
                      .WithField(FieldFor(TD, "fName", "Dealer"))
                      .WithField(FieldFor(TPOL, "fWebPolicyID", "WebPolicyId"))
                      .WithTable(CONT)
                      .WithInnerJoin(CONT, "fCellCaptiveID", LUTCC)
                      .WithInnerJoin(CONT, "ContractIntID", POL)
                      .WithInnerJoin(POL, "PolicyTypeID", POLT, "fPolicyTypeID")
                      .WithInnerJoin(POL, "PolicyIntID", PR, "fPolicyID")
                      .WithInnerJoin(PR, "fClientID", CL)
                      .WithInnerJoin(POL, "PolicyID", C)
                      .WithInnerJoin(PR, "fPolicyID", TPOL)
                      .WithInnerJoin(TPOL, "fAssetID", TA)
                      .WithInnerJoin(TPOL, "fDealerID", TD)
                      .WithInnerJoin(POLT, "ProductTypeID", PT)
                      .WithCondition(searchOption, Condition.EqualityOperators.Contains, searchTerm)
                      .Build();


            //--------------- Assert -----------------------
            Console.WriteLine(replaced);
            Console.WriteLine(@"-----");
            Console.WriteLine(sql);
        }
示例#35
0
        public static string ConfigFilter(String formGuid)
        {
            FormState state = FormState.Approved;
            Range range = Range.Day;
            Show show = Show.five;

            if (HttpContext.Current.Session["State"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["State"].ToString()))
                state = (FormState)Enum.Parse(typeof(FormState), HttpContext.Current.Session["State"].ToString());

            if (HttpContext.Current.Session["Range"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["Range"].ToString()))
                range = (Range)Enum.Parse(typeof(Range), HttpContext.Current.Session["Range"].ToString());

            if (HttpContext.Current.Session["Show"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["Show"].ToString()))
                show = (Show)Enum.Parse(typeof(Show), HttpContext.Current.Session["Show"].ToString());

            lecoati.uMobile.umComponents.Form form = new lecoati.uMobile.umComponents.Form();

            form.primary = new Button("Refresh", new Call("ListRecord", new string[] { formGuid, "1" }));

            FormFieldset fieldSet = new FormFieldset(title: "Filter by");
            form.AddFieldset(fieldSet);

            SelectField selectFilter = new SelectField("State", "State", state.ToString());
            foreach (FormState stateIndex in Enum.GetValues(typeof(FormState)))
                selectFilter.AddOption(stateIndex.ToString(), stateIndex.ToString());
            fieldSet.AddFormItem(selectFilter);

            SelectField selectRange = new SelectField("Range", "Range", range.ToString());
            foreach (Range rangeIndex in Enum.GetValues(typeof(Range)))
                selectRange.AddOption(rangeIndex.ToString(), rangeIndex.ToString());
            fieldSet.AddFormItem(selectRange);

            FormFieldset fieldSetEntries = new FormFieldset(title: "Entries");
            form.AddFieldset(fieldSetEntries);

            SelectField selecShow = new SelectField("Show", "Show", ((int)show).ToString());
            foreach (Show showIndex in Enum.GetValues(typeof(Show)))
                selecShow.AddOption(((int)showIndex).ToString(), showIndex.ToString());
            fieldSetEntries.AddFormItem(selecShow);

            return form.UmGo();
        }
示例#36
0
		void Paint(Element parent)
		{	
			new Div(parent, div=>{
				div.ClassName="span6 offset3 well";
				div.Hide();
			}) ;
			
			SearchDiv= new Div(default(Element), searchdiv=>{
				searchdiv.ClassName= "span6 offset3 nav";
				
				BNew = new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-plus-sign icon-large";
					abn.JSelect().Click(evt=>{
						GridDiv.Hide();
						FormDiv.FadeIn();
						Form.Element().Reset();
						BDelete.Element().Disabled=true;
						BList.Element().Disabled=false;
					});
				});
				
				BDelete= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-remove-sign icon-large";
					abn.Disabled=true;
					abn.JSelect().Click(evt=>{
						RemoveRow();
					});
				});
				
				BList= new IconButton(searchdiv, (abn, ibn)=>{
					ibn.ClassName="icon-reorder icon-large";
					abn.JSelect().Click(evt=>{
						FormDiv.Hide();
						GridDiv.FadeIn();
						BList.Element().Disabled=true;
					});
				});
				
			});
			SearchDiv.AppendTo(parent);
			
			GridDiv= new  Div(default(Element), gdiv=>{
				gdiv.ClassName="span6 offset3";
				TableFuentes= new HtmlTable(gdiv, table=>{
					InitTable(table);
					LoadFuentes(table);
				});
			});
			
			GridDiv.AppendTo(parent);
			
			
			FormDiv= new Div(default(Element), formdiv=>{
				formdiv.ClassName="span6 offset3 well";
				formdiv.Hide();
				Form = new Form(formdiv, f=>{
					f.ClassName="form-horizontal";
					f.Action="api/Fuente/";
					
					var inputId= new InputText(f, e=>{
						e.Name="Id";
						e.Hide();
					}); 
					
					var cbTipo= new SelectField(f, (e)=>{
						e.Name="Tipo";
						e.ClassName="span12";

						new HtmlOption(e, o=>{
							o.Value="";
							o.Selected=true;
							o.Text="Seleccione el tipo ";
						});

						new HtmlOption(e, o=>{
							o.Value="Credito";
							o.Text="Credito";
						});											
						new HtmlOption(e, o=>{
							o.Value="Debito";
							o.Text="Debito";
						});											
												
					});
					
					var fieldCodigo=new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Codigo";
						field.SetPlaceHolder("Codigo del Recurso ## Grupo ##.## Item");
					});
					
					var fieldNombre=new TextField(f,(field)=>{
						field.ClassName="span12";
						field.Name="Nombre";
						field.SetPlaceHolder("Nombre del Recurso");
					});
					
					
					var bt = new SubmitButton(f, b=>{
						b.JSelect().Text("Guardar");
						b.LoadingText(" Guardando ...");
						b.ClassName="btn btn-info btn-block" ;
					});
					
					var vo = new ValidateOptions()
						.SetSubmitHandler( form=>{
							
							bt.ShowLoadingText();
							var action= form.Action+(string.IsNullOrEmpty(inputId.Value())?"create":"update");
							jQuery.PostRequest<BLResponse<Fuente>>(action, form.Serialize(), cb=>{},"json")
								.Success(d=>{
									Cayita.Javascript.Firebug.Console.Log("Success guardar recurso",d);
									if(string.IsNullOrEmpty(inputId.Value()) )
										AppendRow(d.Result[0]);
									else
										UpdateRow(d.Result[0]);
									FormDiv.FadeOut();
									GridDiv.Show ();
									
								})
									.Error((request,  textStatus,  error)=>{
										Cayita.Javascript.Firebug.Console.Log("request", request );
										Div.CreateAlertErrorBefore(form.Elements[0],
										                           textStatus+": "+ request.StatusText);
									})
									.Always(a=>{
										bt.ResetLoadingText();
									});
							
						})	
							.AddRule((rule, msg)=>{
								rule.Element=cbTipo.Element();
								rule.Rule.Required();
								msg.Required("Seleccione tipo de Recurso");
							})
							.AddRule((rule,msg)=>{
								rule.Element=fieldNombre.Element();
								rule.Rule.Required().Maxlength(64);
								msg.Required("Indique el nombre del Recurso").Maxlength("Maximo 64 Caracteres");
							}).AddRule((rule,msg)=>{
								rule.Element=fieldCodigo.Element();
								rule.Rule.Required().Maxlength(5);
								msg.Required("Indique el codigo del Recurso").Maxlength("Maximo 5 caracteres");
							});
					
					f.Validate(vo);					
				});
			});

			FormDiv.AppendTo(parent);
		}