Example #1
0
        /// <summary>
        /// Reakcja na komendę BaseCommand
        /// nawiązuje połączenie z bazą danych oraz wyświetla
        /// dialog dodawania nowej osoby
        /// </summary>
        public void AddContact_Clicked()
        {
            using var db = new MyDatabaseContext();

            var addWindow = new AddWindow();

            if (addWindow.ShowDialog() == true)
            {
                var person = new Person
                {
                    FirstName = addWindow.Firstname.Text.ToUpper(),
                    LastName  = addWindow.Surname.Text.ToUpper(),
                    Age       = Convert.ToInt32(addWindow.Age.Text),

                    Contact = new Contact
                    {
                        City       = addWindow.City.Text.ToUpper(),
                        Street     = addWindow.Street.Text.ToUpper(),
                        HomeNumber = addWindow.HomeNumer.Text.ToUpper(),
                        PostCode   = addWindow.PostCode.Text,
                        PostOffice = addWindow.PostOffice.Text.ToUpper(),
                        Phone      = addWindow.Phone.Text,
                        Email      = addWindow.Email.Text
                    }
                };

                // dodaje użytkownika do bazy oraz zapsiuje zmainy
                db.Persons.Add(addWindow.Person);
                db.SaveChanges();

                // ponowne wczytanie osób z bazy
                mainWindow.personDataModel.Get();
            }
        }
        public void  AddNewProjectAsync(object obj)
        {
            Base.Site newSite = new Base.Site();
            AddWindow add     = new AddWindow(newSite, Consumer, this);

            add.Show();
        }
Example #3
0
        private void ButtonAdd()
        {
            AddWindow addWindow = new AddWindow();

            addWindow.DataContext = new AddViewModel(Cds, dataContext);
            addWindow.Show();
        }
        private void btnAddOrder_Click_1(object sender, RoutedEventArgs e)
        {
            AddWindow win = new AddWindow();
            AddOrder addOrderUc = new AddOrder();

            win.Title = "Orders: " + WorkerId;
            addOrderUc.ParentWin = win;
            win.AddGrid.Children.Add(addOrderUc);
            win.SizeToContent = SizeToContent.WidthAndHeight;

            bool? resDiag = win.ShowDialog();
            if (resDiag.HasValue && resDiag.Value)
            {
                Order toAdd = addOrderUc.newOrder;
                toAdd.WorkerId = WorkerId;
                try
                {
                    MainWindow._repo.AddOrders(toAdd);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message , "Show Orders");
                }
                MainWindow._orders = MainWindow._repo.GetOrder(WorkerId);
                dgShowOrders.ItemsSource = MainWindow._orders;
                dgShowOrders.Items.Refresh();
            }
        }
Example #5
0
        private void exit_Click(object sender, RoutedEventArgs e)
        {
            AddWindow taskWindow = new AddWindow();

            taskWindow.Show();
            this.Close();
        }
Example #6
0
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        AddWindow popup = new AddWindow();

        popup.Check += popup_Check;
        popup.Show();
    }
    private void button1_Click(object sender, RoutedEventArgs e)
    {
        AddWindow winAdd = new AddWindow();

        winAdd.AddItem += new AddItemHandler(winAdd_AddItem);
        winAdd.Show();
    }
Example #8
0
        public static Person AddPerson()
        {
            AddWindow aw = new AddWindow();

            aw.ShowDialog();
            return(CurrentPerson);
        }
        public void AddNewMenu(object obj)
        {
            Base.Menu newMenu = new Base.Menu();
            LayoutWindow           = new Views.Layout(this);
            newMenu.SiteId         = SelectedSite.SiteId;
            newMenu.XamlPageString = Settings.XamlToSring((StackPanel)LayoutWindow.FindName("PageLayout"));
            AddWindow add = new AddWindow(newMenu, Consumer, this);

            add.Show();
        }
        public MainWindow()
        {
            InitializeComponent();
            XMLObjectViewModel viewModel = new XMLObjectViewModel();

            this.DataContext = viewModel;

            // define helper windows
            addWindow             = new AddWindow();
            addWindow.DataContext = viewModel;
        }
Example #11
0
        private void Add_OnClick(object sender, RoutedEventArgs e)
        {
            var locationFromScreen = PointToScreen(new Point(0, 0));
            var addProduct         = new AddWindow(this)
            {
                Top  = locationFromScreen.Y + 20,
                Left = locationFromScreen.X - 10, Topmost = true
            };

            addProduct.Show();
        }
Example #12
0
        private void AddPhone()
        {
            AddWindow addWindow = new AddWindow();

            addWindow.ShowDialog();
            if (PhoneMediator.IsApply)
            {
                Db.Phones.Add(PhoneMediator.Phone);
                Db.SaveChanges();
            }
        }
Example #13
0
        private void Add_Click(object sender, MouseButtonEventArgs e)
        {
            this.Hide();
            var screen = new AddWindow();

            screen.ShowDialog();
            if (screen.DialogResult == true)
            {
                _list.ResetBindings();
            }
            this.Show();
        }
        private void AddButt_Click(object sender, RoutedEventArgs e)
        {
            Window addWindow = new AddWindow();

            addWindow.ShowDialog();
            MesurementsDataGrid.Items.Refresh();

            if (MesurementsDataGrid.Items.Count == 0)
            {
                return;
            }
        }
        private void AddGoodsCommandEv(object parametr)
        {
            AddGoodsViewModel addGoodsViewModel = new AddGoodsViewModel(_mainDataContext);
            AddWindow         DialogWin         = new AddWindow();

            DialogWin.DataContext = addGoodsViewModel;
            if (addGoodsViewModel.CloseAct == null)
            {
                addGoodsViewModel.CloseAct = new Action(() => DialogWin.Close());
            }

            DialogWin.ShowDialog();
        }
Example #16
0
        private async void AddMenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            var adder = new AddWindow()
            {
                Owner = this.TryFindParent <Window>()
            };

            adder.ShowDialog();
            if (adder.IsCommited)
            {
                await this.ViewModel.ReloadIfInitializedAsync();
            }
        }
Example #17
0
        private void UpdatePhone()
        {
            PhoneMediator.Phone = (SelectedPhone.Clone()) as Phone;
            AddWindow addWindow = new AddWindow();

            addWindow.ShowDialog();
            if (PhoneMediator.IsApply)
            {
                Db.Update(PhoneMediator.Phone);
                Db.SaveChanges();
            }
            PhoneMediator.Phone = null;
        }
Example #18
0
        private void AddDebtor()
        {
            var dlg = new AddWindow();  //Creating a new window. This windows is getting a debtor as DataContext

            debtor          = new Debtor();
            dlg.DataContext = debtor;
            if (dlg.ShowDialog() == true)
            {
                debtorList.Add(debtor);
                CurrentIndex  = debtorList.Count - 1;
                CurrentDebtor = debtor;
            }
        }
        private void EditGoodsCommandEv(object parametr)
        {
            Goods goodsSel = parametr as Goods;
            EditeGoodsViewModel editGoodsViewModel = new EditeGoodsViewModel(goodsSel, _mainDataContext);
            AddWindow           DialogWin          = new AddWindow();

            DialogWin.DataContext = editGoodsViewModel;
            if (editGoodsViewModel.CloseAct == null)
            {
                editGoodsViewModel.CloseAct = new Action(() => DialogWin.Close());
            }

            DialogWin.ShowDialog();
        }
Example #20
0
        private void btnADD_Click(object sender, RoutedEventArgs e)
        {
            var Pop = new AddWindow((int)udColumn.Value, (int)udRow.Value);

            Pop.Owner = this;
            if ((bool)Pop.ShowDialog())
            {
                //Add the word to the list of words to draw
                Puzzle.Add(Pop.Word);
            }

            mnuSave.IsEnabled = lbClues.Items.Count > 0;

            ReDrawGrid();
        }
Example #21
0
        public override void Execute(object parameter)
        {
            var selectedItems = GetSelectedItems();

            if (selectedItems.Count == 0)
            {
                return;
            }

            var items = GetProjectItems(selectedItems);

            var dialog = new AddWindow();

            dialog.Initialize(items);
            AppHost.Shell.ShowDialog(dialog);
        }
        private void AddOrderMI_Click_1(object sender, RoutedEventArgs e)
        {
            AddWindow addWin = new AddWindow();
            AddOrder addOrder = new AddOrder();

            addWin.SizeToContent = SizeToContent.WidthAndHeight;

            addOrder.ParentWin = addWin;
            addWin.AddGrid.Children.Add(addOrder);
            addWin.ShowDialog();
            bool? resDiag = addWin.DialogResult;
            if (resDiag.HasValue && resDiag.Value)
            {
                _repo.AddOrders(addOrder.newOrder);
            }
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            AddWindow addWin = new AddWindow();
            AddView addView = new AddView();

            addWin.SizeToContent = SizeToContent.WidthAndHeight;
            addView.ParentWin = addWin;
            addWin.AddGrid.Children.Add(addView);

            bool? resDiag = addWin.ShowDialog();
            if (resDiag.HasValue && resDiag.Value)
            {
                _repo.Add(addView.newWorker);
                _workers = _repo.GetAll();
                dgWorkers.ItemsSource = _workers;
                dgWorkers.Items.Refresh();
            }
        }
        public void OpenAddWindow()
        {
            AddWindow addWindow = new AddWindow();

            if (addWindow.ShowDialog() == false)
            {
                if (addWindow.addNewPhone == null)
                {
                    return;
                }
                else
                {
                    addWindow.addNewPhone.Seller = connectUser.Id;
                    ApplicationContext db = new ApplicationContext();
                    db.Phones.Local.Add(addWindow.addNewPhone);
                    db.SaveChanges();
                }
            }
        }
        public MainWindowViewModel()
        {
            FriendServer friendServer = new FriendServer();
            DataTable    table        = friendServer.GetTable();

            foreach (DataRow item in table.Rows)
            {
                using (MemoryStream memory = new MemoryStream((byte[])item["Head"]))
                {
                    Bitmap       bitmap = (Bitmap)System.Drawing.Image.FromStream(memory);
                    BitmapSource source = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    friends.Add(new Friend()
                    {
                        Nickname = item["Nickname"].ToString(), Head = source
                    });
                }
            }
            CloseCommand = new DelegateCommand(() => {
                Application.Current.Shutdown();
            });

            SelectItemChangedCommand = new DelegateCommand <object>((p) => {
                ListView lv = p as ListView;
                friend      = lv.SelectedItem as Friend;

                //Head= friend.Head;
                //Nickname = friend.Nickname;
            });
            AddCommand = new DelegateCommand(() =>
            {
                addWindow = new AddWindow();
                addWindow.ShowDialog();
            });
            ClickCommand = new DelegateCommand(() =>
            {
                MessageBox.Show("你好");
            });
            CaptureCommand = new DelegateCommand(() =>
            {
                CaptureWindow captureWindow = new CaptureWindow();
                captureWindow.ShowDialog();
            });
        }
Example #26
0
        public Customer AddCustomer()
        {
            vm = new AddWindowViewModel
            {
                CancelCommand = new RelayCommand(o => window.Close()),
                OkCommand     = new RelayCommand(o => { window.DialogResult = true; window.Close(); })
            };

            window = new AddWindow
            {
                DataContext = vm
            };

            var result = window.ShowDialog() ?? false;

            return(!string.IsNullOrEmpty(vm.FirstName) || !string.IsNullOrEmpty(vm.LastName)
                ? result ? vm.Customer : null
                : null);
        }
        public void AddWidget(object parameter)
        {
            //
            // create WidgetOperation object to pass
            // open add window
            //
            WidgetOperation widgetOperation = new WidgetOperation()
            {
                Status = WidgetOperation.OperationStatus.CANCEL,
                Widget = new Widget()
            };
            Window addWdigetWindow = new AddWindow(widgetOperation);

            addWdigetWindow.ShowDialog();

            if (widgetOperation.Status != WidgetOperation.OperationStatus.CANCEL)
            {
                Widgets.Add(widgetOperation.Widget);
            }
        }
Example #28
0
        /// <summary>
        /// obsługa zdarzenia podwójnego kliknięcia myszką na kontrolce ListView
        /// które wyzwala możliwość edycji rekordu występującego pod kursorem myszy
        /// </summary>
        /// <param name="sender">obiekt wysyłający zdarzenie</param>
        /// <param name="e">dodatkowe argumenty</param>
        private void personListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var row = (DatabaseLibrary.Models.Person)personListView.SelectedItem;

            if (row != null)
            {
                var addWindow = new AddWindow(row.ID);
                if (addWindow.ShowDialog() == true)
                {
                    var p = (from person in _context.Persons
                             join contact in _context.Contacts
                             on person.ID equals contact.PersonID
                             where person.ID == row.ID
                             select person).ToList().First();

                    var c = (from contact in _context.Contacts
                             where contact.PersonID == row.ID
                             select contact).ToList().First();

                    p.FirstName  = addWindow.Firstname.Text.ToUpper();
                    p.LastName   = addWindow.Surname.Text.ToUpper();
                    p.Age        = Convert.ToInt32(addWindow.Age.Text);
                    c.City       = addWindow.City.Text.ToUpper();
                    c.Street     = addWindow.Street.Text.ToUpper();
                    c.HomeNumber = addWindow.HomeNumer.Text.ToUpper();
                    c.PostCode   = addWindow.PostCode.Text.ToUpper();
                    c.PostOffice = addWindow.PostOffice.Text.ToUpper();
                    c.Email      = addWindow.Email.Text.ToUpper();
                    c.Phone      = addWindow.Phone.Text.ToUpper();

                    p.Contact = c;

                    // zapisa danych w bazie
                    _context.Update(p);
                    _context.SaveChanges();

                    // odświerzenie listy głównej
                    personDataModel.Get();
                }
            }
        }
Example #29
0
        private void EditDebtor()
        {
            var dlg = new AddWindow();

            dlg.Title = "Edit debitor";


            Debtor temp = new Debtor(); //Creating a temporary debtor to edit

            temp.Name       = CurrentDebtor.Name;
            temp.Amount     = CurrentDebtor.Amount;
            temp.Note       = CurrentDebtor.Note;
            dlg.DataContext = temp;
            if (dlg.ShowDialog() == true) //If confirm is pressed, the temporary debtor is copied to the current debtor

            {
                currentDebtor.Name   = temp.Name;
                currentDebtor.Amount = temp.Amount;
                currentDebtor.Note   = temp.Note;
            }
        }
Example #30
0
 protected void UploadFile_Click(object sender, DirectEventArgs e)
 {
     try
     {
         string filename    = Path.GetFileName(UploadDoc.PostedFile.FileName);
         string contentType = UploadDoc.PostedFile.ContentType;
         using (Stream fs = UploadDoc.PostedFile.InputStream)
         {
             using (BinaryReader br = new BinaryReader(fs))
             {
                 byte[] bytes = br.ReadBytes((Int32)fs.Length);
                 using (MySqlConnection con = new MySqlConnection(MySqlString))
                 {
                     string query = "INSERT INTO pat_monthdoc(Month, Name, Content, Size, SaveDateTime, User) ";
                     query += "VALUES (@Month, @FileName, @Content, @FileSize, @SaveDateTime, @UserName)";
                     using (MySqlCommand cmd = new MySqlCommand(query))
                     {
                         cmd.Connection = con;
                         cmd.Parameters.AddWithValue("@Month", YearMonth.Text);
                         cmd.Parameters.AddWithValue("@FileName", DateTime.Now.ToString("yyyyMM_") + filename);
                         cmd.Parameters.AddWithValue("@Content", bytes);
                         cmd.Parameters.AddWithValue("@FileSize", bytes.Length.ToString());
                         cmd.Parameters.AddWithValue("@SaveDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                         cmd.Parameters.AddWithValue("@UserName", _USER_NAME);
                         con.Open();
                         cmd.ExecuteNonQuery();
                         con.Close();
                     }
                 }
             }
         }
         Common._NotificationShow("上传成功");
         AddWindow.Close();
         show_grid();
     }
     catch (Exception ex)
     {
         Common._ErrorMsgShow("上传失败:" + ex.Message.ToString());
     }
 }
        /// <summary>
        /// Add new sender.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbSenderSelect_btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (cbSenderSelect.ComboBoxText == "")
            {
                System.Windows.MessageBox.Show("Email address is empty."); return;
            }
            AddWindow childWindow = new AddWindow();

            childWindow.Owner = this;
            childWindow.ShowDialog();

            try
            {
                VariableClass.Senders.Add(cbSenderSelect.ComboBoxText, CodePassword.getCodPassword(childWindow.Password));
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("User with such address is already exist.");
                return;
            }
            cbSenderSelect.UpdateComboBox();
        }
Example #32
0
        private void Menu_NewItem_Click(object sender, RoutedEventArgs e)
        {
            //create Window to prompt user for data.
            var createItemWindow = new AddWindow();

            //if 'OK' pressed
            if (createItemWindow.ShowDialog() == true)
            {
                //Get data from create-window.
                string Name            = createItemWindow.Name;
                string Street          = createItemWindow.Street;
                int    StreetNum       = createItemWindow.StreetNum;
                int    ZipCode         = createItemWindow.ZipCode;
                string City            = createItemWindow.City;
                string TreeMonitorList = createItemWindow.TreeMonitorList;


                Location item = new Location(Name, Street, StreetNum, ZipCode, City, TreeMonitorList);

                LocationList items = (LocationList)Resources["LocationList"];
                items.NewItemCommand.Execute(item);
            }
        }
Example #33
0
        public void AddWidget(object parameter)
        {
            //
            // create WidgetOperation object to pass
            // open add window
            //
            WidgetOperation widgetOperation = new WidgetOperation()
            {
                Status = WidgetOperation.OperationStatus.CANCEL,
                Widget = new Widget()
            };
            Window addWdigetWindow = new AddWindow(widgetOperation);

            addWdigetWindow.ShowDialog();

            //
            // TODO consider refactoring and use a class with the Widget object and status
            //
            if (widgetOperation.Status != WidgetOperation.OperationStatus.CANCEL)
            {
                Widgets.Add(widgetOperation.Widget);
            }
        }
 public void Execute(object parameter)
 {
     AddWindow addWindow = new AddWindow();
     addWindow.ShowDialog();
 }
        private void MenuItem_Click_3(object sender, RoutedEventArgs e)
        {
            int index = dgWorkers.Items.IndexOf(dgWorkers.CurrentItem);
            int actId = _workers.ElementAt(index).id;

            //int r = res.id;
            //MessageBox.Show(r.ToString());
            _orders = _repo.GetOrder(actId);

            MessageBoxResult res = MessageBoxResult.None;

            if (_orders.Count() == 0)
            {
                res = MessageBox.Show("orders not found in " + " You want add Order ", _workers.ElementAt(index).FirstName + " " + _workers.ElementAt(index).LastName,
                    MessageBoxButton.YesNo , MessageBoxImage.Question);
            }

            if (_orders.Count() != 0 || res == MessageBoxResult.Yes)
            {

                try
                {
                    AddWindow addWin = new AddWindow();
                    OrderShow orderShow = new OrderShow();

                    addWin.SizeToContent = SizeToContent.WidthAndHeight;
                    addWin.Title = _workers.ElementAt(index).FirstName + " " + _workers.ElementAt(index).LastName;
                    orderShow.ParentWin = addWin;
                    addWin.AddGrid.Children.Add(orderShow);
                    orderShow.WorkerId = _workers.ElementAt(index).id;
                    addWin.ShowDialog();
                }
                    catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 private void newButton_Click(object sender, RoutedEventArgs e)
 {
     AddWindow myAddWindow = new AddWindow();
     myAddWindow.Show();
 }