Ejemplo n.º 1
0
        private void HighlightDuplicates()
        {
            Dictionary <string, List <int> > dictIds         = new System.Collections.Generic.Dictionary <string, List <int> >();
            Dictionary <string, List <int> > dictNames       = new System.Collections.Generic.Dictionary <string, List <int> >();
            Dictionary <string, List <int> > dictAlias       = new System.Collections.Generic.Dictionary <string, List <int> >();
            Dictionary <string, List <int> > dictAliasPlural = new System.Collections.Generic.Dictionary <string, List <int> >();

            foreach (System.Windows.Forms.DataGridViewRow row in dataGridViewX1.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                string id          = row.Cells[(int)ColumnNames.Id].Value == null ? "" : row.Cells[(int)ColumnNames.Id].Value.ToString();
                string name        = row.Cells[(int)ColumnNames.Name].Value == null ? "" : row.Cells[(int)ColumnNames.Name].Value.ToString();
                string alias       = row.Cells[(int)ColumnNames.Alias].Value == null ? "" : row.Cells[(int)ColumnNames.Alias].Value.ToString();
                string aliasPlural = row.Cells[(int)ColumnNames.AliasPlural].Value == null ? "" : row.Cells[(int)ColumnNames.AliasPlural].Value.ToString();

                LookupValue lookupValue = (LookupValue)row.Tag;
                string      errorDescription;

                if (!lookupValue.IsValid(false, out errorDescription))
                {
                    row.Cells[(int)ColumnNames.Id].ErrorText = errorDescription;
                }
                else
                {
                    row.Cells[(int)ColumnNames.Id].ErrorText = "";
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("LookupValueID,LookupID,LookupValueCode,LookupValueDesc,Attribute1,Attribute2,Attribute3,Attribute4,Attribute5,ActiveFlag")] LookupValue lookupValue)
        {
            if (id != lookupValue.LookupValueID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lookupValue);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LookupValueExists(lookupValue.LookupValueID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ActiveFlag"] = new SelectList(_context.LookupValues.Where(lv => lv.ActiveFlag == GlobalData.gY).Join(_context.Lookups.Where(lu => lu.ActiveFlag == GlobalData.gY && lu.LookupCode == GlobalData.YesNo), lv => lv.LookupID, lu => lu.LookupID, (lv, lu) => new { lv.Attribute1, lv.Attribute2 }), "Attribute2", "Attribute1", lookupValue.ActiveFlag);
            ViewData["LookupID"]   = new SelectList(_context.Lookups, "LookupID", "ActiveFlag", lookupValue.LookupID);
            return(View(lookupValue));
        }
Ejemplo n.º 3
0
        public override MicroLatticeElement EvaluatePredicate(Expr e, LookupValue lookup)
        {
            NAryExpr nary = e as NAryExpr;

            if (nary != null &&
                (nary.Fun.FunctionName.Equals("==") || nary.Fun.FunctionName.Equals("!=")))
            {
                Debug.Assert(nary.Args.Length == 2);

                Expr     arg0 = nary.Args[0], arg1 = nary.Args[1];
                Variable var = null;

                // Look for "x OP null" or "null OP x" where OP is "==" or "!=".
                if (arg0 is IdentifierExpr && arg1 is LiteralExpr && ((LiteralExpr)arg1).Val == null)
                {
                    var = ((IdentifierExpr)arg0).Decl;
                }
                else if (arg1 is IdentifierExpr && arg0 is LiteralExpr && ((LiteralExpr)arg0).Val == null)
                {
                    var = ((IdentifierExpr)arg1).Decl;
                }

                if (var != null) // found the pattern
                {
                    return(nary.Fun.FunctionName.Equals("==") ?
                           NullnessLatticeElement.Null :
                           NullnessLatticeElement.NotNull);
                }
            }
            return(Top);
        }
Ejemplo n.º 4
0
        private string GetInsertValues(LookupValue arg, int idx)
        {
            string Id          = (arg.Index ?? (idx + 1)).ToString(),
                   Name        = $"'{arg.Name}'",
                   Description = $"N'{arg.Description}'";

            List <string> insertValues = new List <string>
            {
                Id,
                Name,
                Description
            };

            insertValues.AddRange(
                arg.OtherColumns.Select(Convert.ToBoolean)
                .Select(v => v ? "1" : "0"));

            if (LookupContext.Atom.AdditionalInfo.Temporal.HasTemporal.GetValueOrDefault())
            {
                insertValues.Add($"'{DateTime.UtcNow.ToString()}'");
                insertValues.Add($"'{DateTime.UtcNow.ToString()}'");
            }

            if (LookupContext.Atom.AdditionalInfo.UseSoftDeletes.GetValueOrDefault())
            {
                insertValues.Add(arg.IsDeleted ? "1" : "0");
            }

            return($@"{string.Join(", ", insertValues)}");
        }
Ejemplo n.º 5
0
 public override MicroLatticeElement EvaluateExpression(Expr e, LookupValue lookup)
 {
     if (e is LiteralExpr && ((LiteralExpr)e).Val == null)
     {
         return(NullnessLatticeElement.Null);
     }
     return(Top);
 }
Ejemplo n.º 6
0
 public void Add <TSagaData>(string propertyName, object propertyValue)
 {
     entries[typeof(TSagaData)] = new LookupValue
     {
         PropertyName  = propertyName,
         PropertyValue = propertyValue
     };
 }
Ejemplo n.º 7
0
        private string GetEnumDefinitionType(LookupValue element, int idx, string namePrefix)
        {
            return($@"
/// <summary>
/// {element.Description}
/// </summary>
[EnumMember]
{namePrefix}{element.Name} = {element.Index ?? (idx + 1)}");
        }
Ejemplo n.º 8
0
    /// <summary>
    /// update multiple lines on the grid
    /// </summary>
    private void Save()
    {
        bool isOk = false;

        for (int i = 0; i < dg.Rows.Count; i++)
        {
            if (dg.Rows[i].Cells.FromKey("TermValue").Value == null)
            {
                isOk = false;
            }
            else
            {
                LookupValue lv = LookupValue.GetByKey(Convert.ToInt32(dg.Rows[i].Cells.FromKey("LookupValueId").Value));
                if (lv != null)
                {
                    lv.Sort    = i;
                    lv.Text    = dg.Rows[i].Cells.FromKey("TermValue").Value.ToString();
                    lv.Comment = (dg.Rows[i].Cells.FromKey("Comment").Value == null ? string.Empty : dg.Rows[i].Cells.FromKey("Comment").Value.ToString());
                    //#ACQ8.20 Starts
                    TemplatedColumn col            = (TemplatedColumn)dg.Rows[i].Cells.FromKey("IsTranslateRow").Column;
                    CheckBox        cb             = (CheckBox)((CellItem)col.CellItems[i]).FindControl("IsTranslateRows");
                    bool            isTranslatable = cb.Checked;
                    lv.IsTranslatable = isTranslatable;
                    //#ACQ8.20 Ends

                    if (!lv.Save(SessionState.User.Id))
                    {
                        lbError.CssClass = "hc_error";
                        lbError.Text     = LookupValue.LastError;
                        lbError.Visible  = true;
                        return;
                    }
                    else
                    {
                        isOk = true;
                    }
                }
                else
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = "Lookup value doesn't exists";
                    lbError.Visible  = true;
                    return;
                }
            }
        }

        if (isOk)         // Success
        {
            // Display message of success
            lbError.CssClass = "hc_success";
            lbError.Text     = "Data saved!";
            lbError.Visible  = true;
        }

        UpdateDataView();
    }
Ejemplo n.º 9
0
        public IActionResult Get()
        {
            var lookup = new LookupValue()
            {
                Id   = 1,
                Name = "One"
            };

            return(new JsonResult(lookup));
        }
Ejemplo n.º 10
0
 protected override void SetLookupValue(LookupValue value)
 {
     if (value.Value != null)
     {
         App.WebDriver.ExecuteScript($"Xrm.Page.getAttribute('{LogicalName}').setValue([ {{ id: '{value.Value.Id}', name: '{value.Value.Name.Replace("'", @"\'")}', entityType: '{value.Value.LogicalName}' }} ])");
         App.WebDriver.ExecuteScript($"Xrm.Page.getAttribute('{LogicalName}').fireOnChange()");
     }
     else
     {
         App.App.Entity.ClearValue(value.ToLookupItem(Metadata));
     }
 }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("LookupValueID,LookupID,LookupValueCode,LookupValueDesc,Attribute1,Attribute2,Attribute3,Attribute4,Attribute5,ActiveFlag")] LookupValue lookupValue)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lookupValue);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LookupID"]   = new SelectList(_context.Lookups, "LookupID", "LookupCode", lookupValue.LookupID);
            ViewData["ActiveFlag"] = new SelectList(_context.LookupValues.Where(lv => lv.ActiveFlag == GlobalData.gY).Join(_context.Lookups.Where(lu => lu.ActiveFlag == GlobalData.gY && lu.LookupCode == GlobalData.YesNo), lv => lv.LookupID, lu => lu.LookupID, (lv, lu) => new { lv.Attribute1, lv.Attribute2 }), "Attribute2", "Attribute1", lookupValue.ActiveFlag);
            return(View(lookupValue));
        }
Ejemplo n.º 12
0
        private static LookupValue CreateLookupValue(IDataRecord reader)
        {
            //source_code,	target_concept_id,	target_domain_id,	validstartdate,	validenddate,	source_vocabulary_id,	source_target_concept_id,	source_validstartdate,	source_validenddate,	ingredient_concept_id
            //    1                       2                 3                  4               5               6                       7                                 8                    9                        10


            //source_code,	target_concept_id,	target_domain_id,	validstartdate,	validenddate
            //    1                       2                 3                  4               5


            var sourceCode = string.Intern(reader[0].ToString().Trim());
            int conceptId  = -1;

            if (int.TryParse(reader[1].ToString(), out var cptId))
            {
                conceptId = cptId;
            }

            if (!DateTime.TryParse(reader[3].ToString(), out var validStartDate))
            {
                validStartDate = DateTime.MinValue;
            }

            if (!DateTime.TryParse(reader[4].ToString(), out var validEndDate))
            {
                validEndDate = DateTime.MaxValue;
            }

            var lv = new LookupValue
            {
                ConceptId      = conceptId,
                SourceCode     = sourceCode,
                Domain         = string.Intern(reader[2].ToString().Trim()),
                ValidStartDate = validStartDate,
                ValidEndDate   = validEndDate,
                Ingredients    = new HashSet <int>()
            };

            if (reader.FieldCount > 5)
            {
                lv.SourceConceptId = int.TryParse(reader[6].ToString(), out var scptId) ? scptId : 0;

                if (int.TryParse(reader[9].ToString(), out var ingredient))
                {
                    lv.Ingredients.Add(ingredient);
                }
            }


            return(lv);
        }
Ejemplo n.º 13
0
        public static string TagDelegateTwoLevel(MappingColumn column, ProcessedImportRow processedImportRow)
        {
            string mainCategory = processedImportRow.Row[column.TemplateColumnOrdinal - 1] == DBNull.Value ? "" : processedImportRow.Row[column.TemplateColumnOrdinal - 1].ToString().Trim();
            string subCategory  = processedImportRow.Row[column.TemplateColumnOrdinal] == DBNull.Value ? "" : processedImportRow.Row[column.TemplateColumnOrdinal].ToString().Trim();

            //main category and all sub category is empty, we can continue with the import without categories
            if (string.IsNullOrWhiteSpace(mainCategory) && string.IsNullOrWhiteSpace(subCategory))
            {
                column.IgnoreThisTable = true;
                return("");
            }

            //only main Category is available
            if (!string.IsNullOrWhiteSpace(mainCategory) && string.IsNullOrWhiteSpace(subCategory))
            {
                LookupValue categoryLookup = column.LookupValues.Where(tag => tag.Lookup == mainCategory.ToUpperInvariant()).FirstOrDefault();

                if (categoryLookup != null)
                {
                    return(categoryLookup.ReplacementId.ToString());
                }
                processedImportRow.AddException(new ImportDataException {
                    ExceptionType = ExceptionType.CategoryIsNotValid, TemplateMappingColumn = column.TemplateMappingColumn, TemplateColumnName = column.TemplateColumnName, IsValid = false
                });
                return("");
            }

            //We have  main category and subcategory level 2
            if (!string.IsNullOrWhiteSpace(mainCategory) && !string.IsNullOrWhiteSpace(subCategory))
            {
                string category = string.Format("{0}||{1}", mainCategory, subCategory).ToUpperInvariant();

                LookupValue categoryLookup = column.LookupValues.Where(tag => tag.Lookup == category).FirstOrDefault();

                if (categoryLookup != null)
                {
                    return(categoryLookup.ReplacementId.ToString());
                }
                processedImportRow.AddException(new ImportDataException {
                    ExceptionType = ExceptionType.CategoryIsNotValid, TemplateMappingColumn = column.TemplateMappingColumn, TemplateColumnName = column.TemplateColumnName, IsValid = false
                });
                return("");
            }

            //All other conditions are invalid hierarchy
            processedImportRow.AddException(new ImportDataException {
                ExceptionType = ExceptionType.CategoryIsNotValid, TemplateMappingColumn = column.TemplateMappingColumn, TemplateColumnName = column.TemplateColumnName, IsValid = false
            });
            return("");
        }
Ejemplo n.º 14
0
        //private Base AddLookupValue(AddLookupValueRequest lookupValue)
        //{
        //    Base viewModel = new Base();

        //    try
        //    {

        //    }
        //    catch (Exception exc)
        //    {
        //        viewModel.ResultInfo.Result = Base.ResultInfoDto.ResultEnum.Error;
        //        viewModel.ResultInfo.ErrorMessage = exc.Message;
        //    }

        //    return viewModel;
        //}

        private Base DeleteLookupValue(LookupValue lookupValue)
        {
            Base viewModel = new Base();

            try
            {
            }
            catch (Exception exc)
            {
                viewModel.ResultInfo.Result       = Base.ResultInfoDto.ResultEnum.Error;
                viewModel.ResultInfo.ErrorMessage = exc.Message;
            }

            return(viewModel);
        }
        public string ToWhereClause()
        {
            var sb = new StringBuilder();

            if (IndexNumber == -1)
            {
                //temp hook to handle straight lookups
                sb.Append("FILENAME " + Operator + " '" + LookupValue.Replace("'", "''") + "'");
            }
            else
            {
                sb.Append("INDEX" + IndexNumber.ToString() + " " + Operator + " '" + LookupValue.Replace("'", "''") + "'");
            }
            return(sb.ToString());
        }
Ejemplo n.º 16
0
        public Lookup()
        {
            _table    = new TypologyTable();
            _typology = new LookupKey(this, "Typology");
            _n        = new LookupValue("N", "Nitrogen", "kg/ha");
            _p        = new LookupValue("P", "Phosphorus", "kg/ha");

            DataItems.Add(new DataItem(_table, "Table", typeof(TypologyTable),
                                       DataItemRole.Input, "TypologyTableTag"));
            DataItems.Add(new DataItem(_typology, "Typology", typeof(LookupKey),
                                       DataItemRole.Input, "TypologyTag"));
            DataItems.Add(new DataItem(_n, "N", typeof(LookupValue),
                                       DataItemRole.Output, "NTag"));
            DataItems.Add(new DataItem(_p, "P", typeof(LookupValue),
                                       DataItemRole.Output, "PTag"));
        }
Ejemplo n.º 17
0
        public async Task UpdateUser(string userId)
        {
            var user = await _context.Users.FindAsync(userId);

            user.LastLoggedIn          = DateTime.Now;
            _context.Entry(user).State = EntityState.Modified;
            var apiRequests = await _context.LookupValues.Where(x => x.LookupValuesId == (long)LookupValueEnum.ApiRequests).LastOrDefaultAsync();

            if (apiRequests == null)
            {
                await _context.LookupValues.AddAsync(new LookupValue
                {
                    LookupValuesId = (long)LookupValueEnum.ApiRequests,
                    DataType       = DataType.Integer,
                    DataValue      = "1",
                    Updated        = DateTime.Now
                });
            }
            else
            {
                if (apiRequests.Updated.Date == DateTime.Today)
                {
                    var lastApi = Convert.ToInt32(apiRequests.DataValue);
                    lastApi = lastApi + 1;
                    var newLookup = new LookupValue
                    {
                        DataType       = DataType.Integer,
                        DataValue      = lastApi.ToString(),
                        LookupValuesId = (long)LookupValueEnum.ApiRequests,
                        Updated        = DateTime.Now
                    };
                    await _context.LookupValues.AddAsync(newLookup);
                }
                else
                {
                    await _context.LookupValues.AddAsync(new LookupValue
                    {
                        LookupValuesId = (long)LookupValueEnum.ApiRequests,
                        DataType       = DataType.Integer,
                        DataValue      = "1",
                        Updated        = DateTime.Now
                    });
                }
            }
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 18
0
        public void TestLookups()
        {
            string keyValue     = "target";
            string missingValue = "small sheep";
            Entity lookup       = new Entity("entity", Guid.NewGuid())
            {
                ["key"] = keyValue
            };

            LookupValue target = new LookupValue("entity", "key");

            this.context.Initialize(lookup);

            Assert.AreEqual(lookup.Id, ((EntityReference)target.Convert(keyValue, this.service)).Id);
            Assert.AreEqual(null, (EntityReference)target.Convert(null, this.service));
            Assert.AreEqual(null, (EntityReference)target.Convert(missingValue, this.service));
        }
 private void SetFieldControlValue(object fieldValue)
 {
     if (!HasValueSet || !LookupValue.Equals(fieldValue))
     {
         Clear();
         LookupValue = fieldValue;
         HasValueSet = true;
         if (DataSource != null)
         {
             if (DropList != null)
             {
                 DropList.SelectedIndex = SelectedValueIndex >= 0
                     ? SelectedValueIndex
                     : -1;
             }
             else if (TextField != null)
             {
                 DataRowView view = null;
                 if (SelectedValueIndex >= 0)
                 {
                     view           = _dataSource[SelectedValueIndex];
                     TextField.Text = view["TextField"] as string;
                 }
                 if (Page != null)
                 {
                     var strFieldValue = "0";
                     if (SelectedValueIndex >= 0)
                     {
                         view          = _dataSource[SelectedValueIndex];
                         strFieldValue = ((int)view["ValueField"]).ToString(CultureInfo.InvariantCulture);
                     }
                     else if (Page.IsPostBack)
                     {
                         strFieldValue = Context.Request.Form[HiddenFieldName];
                         if (string.IsNullOrWhiteSpace(strFieldValue))
                         {
                             strFieldValue = "0";
                         }
                     }
                     Page.ClientScript.RegisterHiddenField(HiddenFieldName, strFieldValue);
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 public static int CompareByString(LookupValue x, LookupValue y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return(0);
         }
         else
         {
             return(-1);
         }
     }
     else
     {
         return(x.Description.CompareTo(y.Description));
     }
 }
        /// <summary>
        /// Handles a click on the OK button.
        /// </summary>
        /// <remarks>When the user clicks OK, the dialog is closed by calling
        /// the <see cref="M:Sitecore.Web.UI.Sheer.ClientResponse.CloseWindow">CloseWindow</see> method.</remarks>
        protected override void OK_Click()
        {
            var selectedValue = GridUtil.GetSelectedValue(this.Entities.ID);

            if (!string.IsNullOrEmpty(selectedValue) && selectedValue != "null")
            {
                this.ResetMetadata();

                var value = new LookupValue(this.Metadata.PrimaryKey, this.Metadata.PrimaryField, selectedValue, this.Target);
                SheerResponse.SetDialogValue(value.ToString());

                base.OK_Click();
            }
            else
            {
                SheerResponse.Alert(ResourceManager.Localize("SELECT_RECORD"));
            }
        }
Ejemplo n.º 22
0
        public List <LookupValue> LookupValueGetByGroupName(string groupName)
        {
            List <LookupValue> lookupValues = null;

            using (SqlConnection conn = GetNewConnection())
            {
                List <SqlParameter> paramColl = new List <SqlParameter>();
                paramColl.Add(new SqlParameter()
                {
                    ParameterName = "@GroupName", Value = groupName
                });

                using (SqlCommand command = BuildCommand(usp_LookupValue_SelectByGroup, CommandType.StoredProcedure, paramColl))
                {
                    command.Connection = conn;
                    command.Connection.Open();

                    SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                    while (reader.Read())
                    {
                        LookupValue lookupValue = new LookupValue()
                        {
                            Id          = reader.GetValueOrDefault <int>("Id"),
                            GroupId     = reader.GetValueOrDefault <int>("GroupId"),
                            Name        = reader.GetValueOrDefault <string>("Name"),
                            Value       = reader.GetValueOrDefault <string>("Value"),
                            Description = reader.GetValueOrDefault <string>("Description"),
                            RowStatus   = reader.GetValueOrDefault <string>("RowStatus")
                        };

                        if (lookupValues == null)
                        {
                            lookupValues = new List <LookupValue>();
                        }
                        lookupValues.Add(lookupValue);
                    }

                    reader.Close();
                }
            }

            return(lookupValues);
        }
Ejemplo n.º 23
0
        private string GetInsertValues(LookupValue arg, int idx)
        {
            string Id          = (arg.Index ?? (idx + 1)).ToString(),
                   Name        = $"'{arg.Name}'",
                   Description = $"N'{arg.Description}'";

            List <string> insertValues = new List <string>
            {
                Id,
                Name,
                Description
            };

            insertValues.AddRange(
                arg.OtherColumns.Select(Convert.ToBoolean)
                .Select(v => v ? "1" : "0"));

            return($@"({string.Join(", ", insertValues)})");
        }
Ejemplo n.º 24
0
        protected override GetInitialisationDataResponse Execute(GetInitialisationDataRequest request)
        {
            var response = CreateTypedResponse();

            var instruments = new List <LookupValue>();

            for (var index = 0; index < 10; index++)
            {
                var instrument = new LookupValue
                {
                    Id    = index,
                    Value = "Instrument" + index
                };
                instruments.Add(instrument);
            }

            response.Instruments = instruments;

            return(response);
        }
Ejemplo n.º 25
0
    /// <summary>
    /// Delete multiple values on the grid
    /// </summary>
    private void Delete()
    {
        lbError.Visible = false;
        for (int i = 0; i < dg.Rows.Count; i++)
        {
            TemplatedColumn col = (TemplatedColumn)dg.Rows[i].Cells.FromKey("Select").Column;
            CheckBox        cb  = (CheckBox)((CellItem)col.CellItems[i]).FindControl("g_sd");
            if (cb.Checked)
            {
                LookupValue lgValuesObj = LookupValue.GetByKey(Convert.ToInt32(dg.Rows[i].Cells.FromKey("LookupValueId").Text));
                if (!lgValuesObj.Delete())
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = LookupValue.LastError;
                    lbError.Visible  = true;

                    break;
                }
            }
        }
        UpdateDataView();
    }
Ejemplo n.º 26
0
    private void btAddRow_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        lbError.Visible = false;
        if (txtValue.Text.Length > 0)
        {
            //QC2691 Check for validation of Terms if it already exists was not there so added
            TermList    Termdetails = Term.GetAll("TermValue = '" + txtValue.Text + "' AND TermTypeCode='C'");
            LookupValue lgValuesObj;
            if (Termdetails == null || Termdetails.Count == 0) //#2712
            //if (Termdetails == null) //#2712 Commented
            {
                lgValuesObj = new LookupValue(-1, lookupGroupId, 0, txtValue.Text, txtComment.Text, IsTranslateDefaultOption);
            }
            else
            {
                lgValuesObj = new LookupValue(-1, lookupGroupId, 0, txtValue.Text, txtComment.Text, Termdetails[0].IsTranslatable);
            }

            if (!lgValuesObj.Save(SessionState.User.Id))
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = LookupValue.LastError;
                lbError.Visible  = true;
            }
            else
            {
                txtComment.Text = string.Empty;
                txtValue.Text   = string.Empty;
                UpdateDataView();
            }
        }
        else
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = "Value cannot be empty";
            lbError.Visible  = true;
        }
    }
Ejemplo n.º 27
0
 public override MicroLatticeElement EvaluateExpression (Expr e, LookupValue lookup)
 {
     if (e is LiteralExpr && ((LiteralExpr)e).Val == null)
     {
         return NullnessLatticeElement.Null;
     }
     return Top;
 }
Ejemplo n.º 28
0
        public override MicroLatticeElement EvaluatePredicate (Expr e, LookupValue lookup)
        {
            NAryExpr nary = e as NAryExpr;
            if (nary != null && 
                    (nary.Fun.FunctionName.Equals("==") || nary.Fun.FunctionName.Equals("!=")))
            {
                Debug.Assert(nary.Args.Length == 2);

                Expr arg0 = nary.Args[0], arg1 = nary.Args[1];
                Variable var = null;

                // Look for "x OP null" or "null OP x" where OP is "==" or "!=".
                if (arg0 is IdentifierExpr && arg1 is LiteralExpr && ((LiteralExpr)arg1).Val == null)
                {
                    var = ((IdentifierExpr)arg0).Decl;
                }
                else if (arg1 is IdentifierExpr && arg0 is LiteralExpr && ((LiteralExpr)arg0).Val == null)
                {
                    var = ((IdentifierExpr)arg1).Decl;
                }

                if (var != null) // found the pattern
                {
                    return nary.Fun.FunctionName.Equals("==") ? 
                        NullnessLatticeElement.Null : 
                        NullnessLatticeElement.NotNull;
                }
            }
            return Top;
        }
Ejemplo n.º 29
0
        public LookupValueRepository()
        {
            _BodyStyles = new List <LookupValue>
            {
                new LookupValue {
                    Description = "Car"
                },
                new LookupValue {
                    Description = "SUV"
                },
                new LookupValue {
                    Description = "Truck"
                },
                new LookupValue {
                    Description = "Van"
                },
            };

            _exteriorColors = new List <LookupValue>
            {
                new LookupValue {
                    Description = "Black"
                },
                new LookupValue {
                    Description = "Blue"
                },
                new LookupValue {
                    Description = "Brown"
                },
                new LookupValue {
                    Description = "Green"
                },
                new LookupValue {
                    Description = "Red"
                },
                new LookupValue {
                    Description = "Orange"
                },
                new LookupValue {
                    Description = "Yellow"
                },
                new LookupValue {
                    Description = "White"
                },
            };

            _interiorColors = new List <LookupValue>
            {
                new LookupValue {
                    Description = "Black"
                },
                new LookupValue {
                    Description = "Blue"
                },
                new LookupValue {
                    Description = "Red"
                },
                new LookupValue {
                    Description = "Tan"
                },
            };

            _price = new List <LookupValue>();
            List <string> listPrice = new List <string>();

            for (int i = 10000; i <= 100000; i++)
            {
                if (i % 5000 == 0) //5000 dollar increments
                {
                    var x = new LookupValue {
                        Description = i.ToString()
                    };
                    _price.Add(x);
                }
            }
            _purchaseTypes = new List <LookupValue>
            {
                new LookupValue {
                    Description = "Bank Finance"
                },
                new LookupValue {
                    Description = "Cash"
                },
                new LookupValue {
                    Description = "Dealer Finance"
                },
            };

            _states = new List <LookupValue>
            {
                new LookupValue {
                    Description = "IN"
                },
                new LookupValue {
                    Description = "KY"
                },
                new LookupValue {
                    Description = "MN"
                },
                new LookupValue {
                    Description = "OH"
                },
                new LookupValue {
                    Description = "TN"
                },
            };

            _transmissionTypes = new List <LookupValue>
            {
                new LookupValue {
                    Description = "Automatic"
                },
                new LookupValue {
                    Description = "Manual"
                },
            };

            _userRoles = new List <LookupValue>
            {
                new LookupValue {
                    Description = "Admin"
                },
                new LookupValue {
                    Description = "Sales"
                },
                new LookupValue {
                    Description = "Disabled"
                },
            };

            _years = new List <LookupValue>();
            //Generate years between 2000 and current year + 1 as per app specs.
            List <int> listYears = Enumerable.Range(2000, DateTime.Now.Year - 1998).ToList();

            foreach (var i in listYears)
            {
                var x = new LookupValue {
                    Description = i.ToString()
                };
                _years.Add(x);
            }

            _condition = new List <LookupValue>
            {
                new LookupValue {
                    Description = "New"
                },
                new LookupValue {
                    Description = "Used"
                }
            };
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Populates existing information for update purpose, if it is text box then it fills the value
        /// if it is dropdown list then it chooses from one of the alternatives supplied by FillControls() method
        /// </summary>
        private void PopulateExistingData()
        {
            //if (theArrival.IsNew) return;
            GRNStatusNew GRNStatus;

            GRNStatusNew.TryParse(theArrival.GRNStatus.ToString(), out GRNStatus);
            if (GRNStatus == GRNStatusNew.New || GRNStatus == GRNStatusNew.NotCreated)
            {
                btnSave.Enabled = true;
            }
            else
            {
                btnSave.Enabled = false;
                btnSave.ToolTip = "Can't Update Arrival because this step is at " + GRNStatus.ToString() + " Stage";
            }
            if (theArrival.WarehouseID != WarehouseBLL.CurrentWarehouse.WarehouseId)
            {
                Response.Redirect("ErrorPage.aspx");
            }
            try
            {
                lblClient.Text             = theArrival.ClientName;
                lblWarehouse.Text          = WarehouseBLL.CurrentWarehouse.WarehouseName;
                isNonTruck.Checked         = theArrival.IsNonTruck;
                cboCommodity.SelectedValue = theArrival.CommodityID.ToString();
                //chkIsSourceDetermined.Checked = theArrival.IsLocationKnown;
                if (!theArrival.IsLocationKnown)
                {
                    cboRegion.SelectedValue = Guid.Empty.ToString();
                }
                else
                {
                    LookupValue lv = SimpleLookup.Lookup(LookupTypeEnum.Woredas).GetDictionary()[theArrival.WoredaID];
                    cboRegion.SelectedValue = lv.RegionID.ToString();
                    cboRegion_SelectedIndexChanged(this, EventArgs.Empty);
                    cboZone.SelectedValue = lv.ZoneID.ToString();
                    cboZone_SelectedIndexChanged(this, EventArgs.Empty);
                    cboWoreda.SelectedValue = theArrival.WoredaID.ToString();
                    txtSpecificArea.Text    = theArrival.SpecificArea;
                }
                cboProductionYear.SelectedValue = theArrival.ProductionYear.ToString();
                txtProcessingCenter.Text        = theArrival.ProcessingCenter;
                txtNumberOfBags.Text            = theArrival.NumberofBags.ToString() == "0" ? "" : theArrival.NumberofBags.ToString();
                txtWeight.Text = theArrival.VoucherWeight.ToString() == "0" ? "" : theArrival.VoucherWeight.ToString();

                if ("1/1/1901" == theArrival.DateTimeReceived.ToShortDateString() || theArrival.DateTimeReceived.ToShortDateString() == "1/1/0001")
                {
                    txtArrivalDate.Text = "";
                    txtTimeArrival.Text = "";
                }
                else
                {
                    txtArrivalDate.Text = theArrival.DateTimeReceived.ToShortDateString();
                    txtTimeArrival.Text = theArrival.DateTimeReceived.ToShortTimeString();
                }
                txtRemark.Text = theArrival.Remark;
                if (!theArrival.IsNonTruck)
                {
                    chkIsTruckInCompound.Checked = theArrival.IsTruckInCompound;
                    txtDriverName.Text           = theArrival.DriverName;
                    txtLicenseNo.Text            = theArrival.LicenseNumber;
                    txtPlaceIssued.Text          = theArrival.LicenseIssuedPlace;
                    txtPlateNo.Text         = theArrival.TruckPlateNumber;
                    txtTrailerPlateNo.Text  = theArrival.TrailerPlateNumber;
                    txtNoPlomps.Text        = theArrival.VoucherNumberOfPlomps.ToString() == "0" ? "" : theArrival.VoucherNumberOfPlomps.ToString();
                    txtTrailerNoPlomps.Text = theArrival.VoucherNumberOfPlompsTrailer.ToString() == "0" ? "" : theArrival.VoucherNumberOfPlompsTrailer.ToString();
                }
                txtVoucherNo.Text   = theArrival.VoucherNumber;
                hdnHasVoucher.Value = theArrival.HasVoucher.ToString();
                //chkIsBiProduct.Checked = theArrival.IsBiProduct;
                if (Guid.Empty == theArrival.VoucherCommodityTypeID || string.IsNullOrEmpty(theArrival.VoucherCommodityTypeID.ToString()))
                {
                    cboCommodityType.SelectedIndex = 0;
                    cboCommodityType.Enabled       = false;
                }
                else
                {
                    cboCommodityType.SelectedValue = theArrival.VoucherCommodityTypeID.ToString();
                }
            }
            catch (Exception ex)
            {
                //lblMessage.Text = "Failed to populate existing data!";

                Messages.SetMessage("Existing data cannot be retrieved.  Please try again.", WarehouseApplication.Messages.MessageType.Error);
            }
        }
Ejemplo n.º 31
0
        protected override void Execute(CodeActivityContext context)
        {
            DataTable  dataTable         = DataTable.Get(context);
            string     lookupValue       = LookupValue.Get(context);
            DataColumn dataColumn        = DataColumn.Get(context);
            DataColumn targetDataColumn  = TargetDataColumn.Get(context);
            Int32      columnIndex       = ColumnIndex.Get(context);
            Int32      targetColumnIndex = ColumnIndex.Get(context);
            string     columnName        = ColumnName.Get(context);
            string     targetColumnName  = TargetColumnName.Get(context);

            object cellValue = null;
            Int32  rowIndex  = 0;

            try
            {
                int beginIndex = 0, endInex = 0;

                DataColumn beginColumn = new DataColumn();
                if (dataColumn != null)
                {
                    beginIndex = dataTable.Columns.IndexOf(dataColumn);
                }
                else if (columnName != null && columnName != "")
                {
                    beginIndex = dataTable.Columns.IndexOf(columnName);
                }
                else
                {
                    beginIndex = columnIndex;
                }
                if (targetDataColumn != null)
                {
                    endInex = dataTable.Columns.IndexOf(targetDataColumn);
                }
                else if (targetColumnName != null && targetColumnName != "")
                {
                    endInex = dataTable.Columns.IndexOf(targetColumnName);
                }
                else
                {
                    endInex = targetColumnIndex;
                }

                if (beginIndex < 0 || endInex < 0 || beginIndex > endInex)
                {
                    SharedObject.Instance.Output(SharedObject.enOutputType.Error, "数据表列索引有误,请检查开始列与结束列");
                    return;
                }

                DataRowCollection dataRows = dataTable.Rows;
                for (int index = beginIndex; index < endInex; index++)
                {
                    foreach (DataRow datarow in dataRows)
                    {
                        object data    = datarow[index];
                        string dataStr = data as string;
                        if (dataStr.Equals(lookupValue))
                        {
                            rowIndex  = dataRows.IndexOf(datarow);
                            cellValue = data;
                            break;
                        }
                    }
                }
                if (CellValue != null)
                {
                    CellValue.Set(context, cellValue);
                }
                if (RowIndex != null)
                {
                    RowIndex.Set(context, rowIndex);
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "查找数据表失败", e.Message);
            }
        }
Ejemplo n.º 32
0
 public bool TryGet(Type sagaType, out LookupValue value)
 {
     return(entries.TryGetValue(sagaType, out value));
 }