Example #1
0
        private void Method3TextChanged(object sender, string sourcetarget)
        {
            TextBox txt = sender as TextBox;

            if (Method3Grid.SelectedIndex == -1)
            {
                return;
            }

            if (txt != null)
            {
                for (int i = 0; i < Method3Grid.Items.Count; i++)
                {
                    if (i == Method3Grid.SelectedIndex)
                    {
                        object      item = Method3Grid.Items.GetItemAt(i);
                        ValueMapRow row  = item as ValueMapRow;
                        if (row != null)
                        {
                            if (sourcetarget == "Source")
                            {
                                row.Source = txt.Text;
                            }
                            else if (sourcetarget == "Target")
                            {
                                row.Target = txt.Text;
                            }
                        }
                    }
                }
            }
        }
        private void saveM3()
        {
            // Value Map
            System.Xml.XmlNodeList nodes = getFieldNodes(this.FieldGrid.SelectedIndex + 1);
            if (nodes != null)
            {
                DataGrid grid = this.Method3Grid as DataGrid;
                if (grid == null)
                {
                    return;
                }

                try
                {
                    string method = getMethodVal();
                    nodes[0].SelectSingleNode("Method").InnerText = method;
                    //DataGridRow row0 = (DataGridRow)Method3Grid.ItemContainerGenerator.ContainerFromIndex(0);
                    //TextBox txt = ((TextBox)Method3Grid.Columns[0].GetCellContent(row0));
                    trimNodes(nodes, 3);
                    System.Xml.XmlNode noder = nodes[0].SelectSingleNode(method);
                    if (noder == null)
                    {
                        noder = _xml.CreateElement(method);
                        nodes[0].AppendChild(noder);
                    }
                    noder.RemoveAll();
                    for (int s = 0; s < grid.Items.Count; s++)
                    {
                        object      values = grid.Items[s];
                        ValueMapRow row    = grid.Items.GetItemAt(s) as ValueMapRow;
                        if (row != null)
                        {
                            System.Xml.XmlNode snode = _xml.CreateElement("sValue");
                            snode.InnerText = row.Source;
                            noder.AppendChild(snode);
                            System.Xml.XmlNode tnode = _xml.CreateElement("tValue");
                            tnode.InnerText = row.Target;
                            noder.AppendChild(tnode);
                        }
                    }
                    System.Xml.XmlNode othnode = _xml.CreateElement("Otherwise");
                    string             oth     = Method3Otherwise.Text;
                    if (oth.StartsWith("\n ") || oth.Equals(""))
                    {
                        oth = "None";
                    }
                    othnode.InnerText = oth;
                    noder.AppendChild(othnode);
                    saveFieldGrid();
                }
                catch { }
            }
        }
        private void setPreviewValueMapRows(string attrName)
        {
            DataGrid grid = PreviewGrid;

            grid.Items.Clear();
            string targName = getTargetFieldName();

            for (int i = 0; i < _datarows.Count; i++)
            {
                string textval = "";
                try
                {
                    if (attrName == null)
                    {
                        textval = targName + "=None";
                    }
                    else
                    {
                        System.Xml.XmlAttribute att = _datarows[i].Attributes[attrName];
                        if (att != null)
                        {
                            try
                            {
                                textval = att.InnerText;
                                for (int r = 0; r < Method3Grid.Items.Count; r++)
                                {
                                    // value map replace function
                                    ValueMapRow row = Method3Grid.Items.GetItemAt(r) as ValueMapRow;
                                    if (att.InnerText.ToString() == row.Source.ToString())
                                    {
                                        textval = textval.Replace(row.Source, row.Target);
                                    }
                                    else if (Method3Otherwise.Text != "" && Method3Otherwise.Text != null)
                                    {
                                        textval = Method3Otherwise.Text;
                                    }
                                }
                                textval = targName + "=" + textval;
                            }
                            catch { textval = targName + "=" + "None"; }
                        }
                    }
                }
                catch { textval = targName + "=" + "None"; }
                grid.Items.Add(new PreviewRow()
                {
                    Value = textval
                });
            }
        }
Example #4
0
        private void setPreviewValueMapRows(string attrName)
        {
            DataGrid grid = PreviewGrid;

            grid.Items.Clear();
            string targName = getTargetFieldName();

            if (_datarows != null)
            {
                for (int i = 0; i < _datarows.Count; i++)
                {
                    string textval = "";
                    try
                    {
                        if (attrName == null)
                        {
                            textval = targName + "=None";
                        }
                        else
                        {
                            System.Xml.XmlAttribute att = _datarows[i].Attributes[attrName];
                            if (att != null)
                            {
                                try
                                {
                                    textval = att.InnerText;
                                    bool found = false;
                                    for (int r = 0; r < Method3Grid.Items.Count; r++)
                                    {
                                        ValueMapRow row = Method3Grid.Items.GetItemAt(r) as ValueMapRow;
                                        // value map replace function
                                        decimal numSource, numTarget;
                                        bool    canConvert1 = decimal.TryParse(att.InnerText, out numSource);
                                        bool    canConvert2 = decimal.TryParse(row.Source.ToString(), out numTarget);
                                        if ((canConvert1 && canConvert2) && numSource.Equals(numTarget))
                                        {
                                            textval = row.Target.ToString();//textval.Replace(row.Source, row.Target);
                                            found   = true;
                                        }
                                        else if (att.InnerText == row.Source.ToString())
                                        {
                                            textval = row.Target.ToString();//textval.Replace(row.Source, row.Target);
                                            found   = true;
                                        }
                                    }
                                    if (Method3Otherwise.Text != "" && Method3Otherwise.Text != null && !found)
                                    {
                                        textval = Method3Otherwise.Text;
                                    }
                                    textval = targName + "=" + textval;
                                }
                                catch { textval = targName + "=" + "None"; }
                            }
                        }
                    }
                    catch { textval = targName + "=" + "None"; }
                    grid.Items.Add(new PreviewRow()
                    {
                        Value = textval
                    });
                }
            }
        }