Пример #1
0
        private void ValidateRule(object OriginalSource)
        {
            if (OriginalSource is TextBox)
            {
                TextBox tb = OriginalSource as TextBox;
                if (tb.Tag != null)
                {
                    DynamicRules dr = tb.Tag as DynamicRules;
                    if (dr != null)
                    {
                        foreach (DynamicRule r in dr)
                        {
                            if (r.RuleEquals.ToLower() != tb.Text.Trim().ToLower())
                            {
                                if (BrushDefault == null)
                                {
                                    BrushDefault = tb.BorderBrush;
                                }

                                tb.BorderBrush = new SolidColorBrush(Colors.Red);

                                return;
                            }
                        }
                    }
                }
                //tb.BorderBrush = System.Windows.Media.LinearGradientBrush.;
                if (BrushDefault != null)
                {
                    tb.BorderBrush = BrushDefault;
                }
            }
        }
Пример #2
0
        //private void CodeSetNameComboBox_DropDownOpened(object sender, EventArgs e)
        //{
        //    i9ComboBox i9cb = (i9ComboBox)sender;

        //    if (!String.IsNullOrEmpty(i9cb.i9BindCodeSetName) && i9cb.Items.Count <= 0)
        //    {
        //        ClientDataAccess cda = new ClientDataAccess();
        //        DataTable dt = cda.GetDataTable("SELECT Code, CodeText FROM i9Code WHERE Enabled <> 0 AND CodeSetName = " + DataAccessUtilities.GetDBStr(i9cb.i9BindCodeSetName) + " Order By CodeText ", "i9Code");
        //        i9ComboBox.PopulateCombobox(i9cb, dt, "i9Code");
        //    }
        //}

        //private void BuildStackUI()
        //{
        //    try
        //    {
        //        foreach (DataRow dr in mTableSchema.Tables[this.mTableName].Rows)
        //        {
        //            string ColumnName = dr["ColumnName"].ToString();
        //            Label l = new Label()
        //            {
        //                Height=28,
        //                Name=ColumnName + "Label",
        //                HorizontalContentAlignment= System.Windows.HorizontalAlignment.Right,
        //                Content = ColumnName
        //            };

        //            TextBox tb = new TextBox()
        //            {
        //                Height=28,
        //                Name=ColumnName + "TextBox",
        //                TextAlignment = System.Windows.TextAlignment.Left,
        //                HorizontalContentAlignment= System.Windows.HorizontalAlignment.Right,
        //            };

        //            //tb.TextChanged += new TextChangedEventHandler(TextBox_TextChanged);
        //            //tb.LostFocus += new RoutedEventHandler(TextBox_LostFocus);
        //            //AddRules(tb);

        //            RulesValidation myRulesValidation = new RulesValidation();
        //            myRulesValidation.module = "TestModule";
        //            myRulesValidation.table = this.mTableName;
        //            myRulesValidation.column = ColumnName;
        //            myRulesValidation.data = mCollectionView;

        //            Binding bindMyColumn = new Binding();
        //            bindMyColumn.Path = new PropertyPath(ColumnName);
        //            bindMyColumn.ValidationRules.Clear();
        //            bindMyColumn.ValidationRules.Add(myRulesValidation);
        //            bindMyColumn.ValidatesOnDataErrors = true;
        //            tb.SetBinding(TextBox.TextProperty, bindMyColumn);
        //            //bindMyColumn.Source = mDataView;

        //            StackLabels.Children.Add(l);
        //            StackFields.Children.Add(tb);
        //        }
        //    }
        //    catch (FileNotFoundException ex)
        //    {
        //        MessageBox.Show(ex.Message.ToString());
        //    }
        //}

        private void AddRules(TextBox tb)
        {
            if (tb.Name.ToLower() == "phonetypecodetextbox")
            {
                DynamicRules mDynRules = new DynamicRules();
                DynamicRule  dr        = new DynamicRule()
                {
                    RuleEquals = "W"
                };
                mDynRules.Add(dr);

                tb.Tag = mDynRules;
            }
        }
        //private void CodeSetNameComboBox_DropDownOpened(object sender, EventArgs e)
        //{
        //    i9ComboBox i9cb = (i9ComboBox)sender;

        //    if (!String.IsNullOrEmpty(i9cb.i9BindCodeSetName) && i9cb.Items.Count <= 0)
        //    {
        //        ClientDataAccess cda = new ClientDataAccess();
        //        DataTable dt = cda.GetDataTable("SELECT Code, CodeText FROM i9Code WHERE Enabled <> 0 AND CodeSetName = " + DataAccessUtilities.GetDBStr(i9cb.i9BindCodeSetName) + " Order By CodeText ", "i9Code");
        //        i9ComboBox.PopulateCombobox(i9cb, dt, "i9Code");
        //    }
        //}

        //private void BuildStackUI()
        //{
        //    try
        //    {
        //        foreach (DataRow dr in mTableSchema.Tables[this.mTableName].Rows)
        //        {
        //            string ColumnName = dr["ColumnName"].ToString();
        //            Label l = new Label() 
        //            {
        //                Height=28,
        //                Name=ColumnName + "Label",
        //                HorizontalContentAlignment= System.Windows.HorizontalAlignment.Right,
        //                Content = ColumnName
        //            };

        //            TextBox tb = new TextBox() 
        //            {
        //                Height=28,
        //                Name=ColumnName + "TextBox",
        //                TextAlignment = System.Windows.TextAlignment.Left,
        //                HorizontalContentAlignment= System.Windows.HorizontalAlignment.Right,
        //            };

        //            //tb.TextChanged += new TextChangedEventHandler(TextBox_TextChanged);
        //            //tb.LostFocus += new RoutedEventHandler(TextBox_LostFocus);
        //            //AddRules(tb);

        //            RulesValidation myRulesValidation = new RulesValidation();
        //            myRulesValidation.module = "TestModule";
        //            myRulesValidation.table = this.mTableName;
        //            myRulesValidation.column = ColumnName;
        //            myRulesValidation.data = mCollectionView;

        //            Binding bindMyColumn = new Binding();
        //            bindMyColumn.Path = new PropertyPath(ColumnName);
        //            bindMyColumn.ValidationRules.Clear();
        //            bindMyColumn.ValidationRules.Add(myRulesValidation);
        //            bindMyColumn.ValidatesOnDataErrors = true;
        //            tb.SetBinding(TextBox.TextProperty, bindMyColumn);
        //            //bindMyColumn.Source = mDataView;

        //            StackLabels.Children.Add(l);
        //            StackFields.Children.Add(tb);
        //        }
        //    }
        //    catch (FileNotFoundException ex)
        //    {
        //        MessageBox.Show(ex.Message.ToString());
        //    }
        //}

        private void AddRules(TextBox tb)
        {
            if (tb.Name.ToLower() == "phonetypecodetextbox")
            {
                DynamicRules mDynRules = new DynamicRules();
                DynamicRule dr = new DynamicRule() { RuleEquals = "W" };
                mDynRules.Add(dr);

                tb.Tag = mDynRules;
            }
        }