Esempio n. 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            TypePay = this.Owner as W_TypePay;

            cb.ItemsSource = ClassSync.TypesPayDB.t;

            string name = sub + "_" + this.xName.Content + "x" + this.yName.Content;

            b = (Button)(TypePay.FindName(name));

            if (b != null)
            {
                int indx = -1;

                if (int.TryParse(b.ToolTip == null ? "-1" : b.ToolTip.ToString().Replace("TypesPay", ""), out indx))
                {
                    cb.SelectedItem = ClassBond.getTypesPayDBFromId(indx);
                }
            }
        }
Esempio n. 2
0
        public void setSelected(GroupBox grpBox, string textSelector)
        {
            bool flgrbt = false;
            //    Grid grd = (Grid)grpBox.Content;
            UIElementCollection uiec = panelA.Children;

            foreach (UIElement uelement in uiec)
            {
                if (typeof(RadioButton) == uelement.GetType())
                {
                    RadioButton rbtn = (RadioButton)uelement;
                    rbtn.IsChecked = false;
                    if (rbtn.Content.ToString() == textSelector)
                    {
                        rbtn.IsChecked = true;
                        flgrbt         = true;
                    }
                }
            }
            uiec = panelB.Children;

            foreach (UIElement uelement in uiec)
            {
                if (typeof(RadioButton) == uelement.GetType())
                {
                    RadioButton rbtn = (RadioButton)uelement;
                    rbtn.IsChecked = false;
                    if (rbtn.Content.ToString() == textSelector)
                    {
                        rbtn.IsChecked = true;
                        flgrbt         = true;
                    }
                }
            }
            if ((!flgrbt) && (textSelector.Substring(0, textSelector.Length > 15 ? 15 : 0) == "_TypesPayDynamic"))
            {
                int indx = -1;
                if (int.TryParse(textSelector == null ? "-1" : textSelector.Replace("_TypesPayDynamic", ""), out indx))
                {
                    cb.SelectedItem = ClassBond.getTypesPayDBFromId(indx);
                }
            }

            if ((!flgrbt) && (textSelector.Substring(0, textSelector.Length > 13 ? 13 : 0) == "Products id=["))
            {
                string sd = textSelector.Substring(textSelector.IndexOf("[") + 1, textSelector.IndexOf("]") - textSelector.IndexOf("[") - 1);

                Guid g = Guid.Parse(sd);

                List <Class.ClassProducts.product> lp = Class.ClassProducts.listProducts.FindAll(l => l.CustumerId == g);

                switch (lp.Count)
                {
                case 0: statusMes.Content = ("С таким именем продукт не найден "); this.xtbc.SelectedIndex = 3; _expander.IsExpanded = true; break;

                case 1: statusMes.Content = (""); xDescription.Text = lp[0].Name; break;

                default:
                    Class.ClassProducts.product pe = list.SelectedItem as Class.ClassProducts.product;
                    if (pe == null)
                    {
                        this.xtbc.SelectedIndex = 3;
                        _expander.IsExpanded    = true;
                    }

                    //    else

                    xDescription.Text = lp[0].Name;

                    break;
                }
            }
        }