Ejemplo n.º 1
0
        public void ReadDataBaseMobilePhone()
        {
            DataBaseMobilePhone readDbMbp       = new DataBaseMobilePhone();
            List <MobilePhone>  MobilePhoneList = readDbMbp.GetDataBase();
            List <MobilePhone>  items           = new List <MobilePhone>();

            for (int i = 0; i < MobilePhoneList.Count; i++)

            {
                int    id           = MobilePhoneList[i].id;
                string model        = MobilePhoneList[i].model;
                string manufacturer = MobilePhoneList[i].manufacturer;
                string price        = MobilePhoneList[i].price;



                items.Add(new MobilePhone()
                {
                    id = MobilePhoneList[i].id, model = MobilePhoneList[i].model, manufacturer = MobilePhoneList[i].manufacturer, price = MobilePhoneList[i].price
                });
            }

            lvMobilePhone.ItemsSource = items;

            //lvMobilePhone.ItemsSource = MobilePhoneList;
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            DataBaseAuth init = new DataBaseAuth();

            init.Init();

            DataBaseMobilePhone initDbMbp = new DataBaseMobilePhone();

            initDbMbp.Init();


            ReadDataBaseMobilePhone();

            lvMobilePhone.Visibility = Visibility.Hidden;
            //lvMobilePhone.ContextMenu.
            //Правильная версия



            Window   = new Log2(dialogLW, thread);
            dialogLW = Window.ShowWindow("Ошибка");

            Thread.Sleep(3000);
            dialogLW.tbError.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => { dialogLW.tbError.Text += "Получил управление потоком \n"; }));

            Thread.Sleep(3000);

            ErrorWithThread errwiththread = new ErrorWithThread("Главное окно загружено\nНажмите кнопку \"ДОБАВИТЬ\" для демонстрации работы консоли\n", dialogLW);

            errwiththread.LogWindow();
        }
Ejemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MainWindow          mv  = this.Owner as MainWindow;
            DataBaseMobilePhone add = new DataBaseMobilePhone();

            add.Add(tbxModel.Text, tbxManufacturer.Text, tbxPrice.Text);
            mv.ReadDataBaseMobilePhone();


            Close();
        }
Ejemplo n.º 4
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (lvMobilePhone.SelectedItem != null)
            {
                MobilePhone list = new MobilePhone();

                list = (MobilePhone)lvMobilePhone.SelectedItem;

                int id = list.id;


                DataBaseMobilePhone dbMF = new DataBaseMobilePhone();
                dbMF.Remove(id);

                ReadDataBaseMobilePhone();
            }
        }