示例#1
0
        private void AddHost_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (errorMessages.Any())
                {
                    string err = "Exception: ";
                    foreach (var item in errorMessages)
                    {
                        err += "\n" + item;
                    }

                    MessageBox.Show(err);
                    return;
                }

                if (ID.Text == "" || Name.Text == "" || LastName.Text == "" || Email.Text == "")
                {
                    MessageBox.Show($"you need to fill all details", "", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                if (this.CollectionClearance.Text == "No")
                {
                    host.CollectionClearance = false;
                }
                else
                {
                    host.CollectionClearance = true;
                }

                BankBranch bankBranch = this.BankBranch.SelectedItem as BankBranch;
                host.BankBranchDetails = bankBranch;
                int hh = host.HostKey;
                bl.AddHost(host);
                host             = new BE.Host();
                this.DataContext = host;
                this.Close();
                MessageBox.Show($"The Host was received by the system");

                BE.Host h = bl.GetHostById(hh);
                MessageBox.Show("Your password is: " + h.HostPassword.ToString());
            }
            catch (FormatException)
            {
                MessageBox.Show("check your input and try again");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void CreatBut(object sender, RoutedEventArgs e)
        {
            if (State == "create")
            {
                Host.BankDetales.BankNumber    = Convert.ToUInt16(BankNum.Text);
                Host.BankDetales.BranchAddress = BranchAddress.Text;
                Host.BankDetales.BranchCity    = BranchCity.Text;
                //Host.CollectingClearance = ClearneceCB.IsEnabled;
                try { bl.AddHost(Host); }
                catch (DuplicateKeyException ex) { MessageBox.Show(ex.Message, "שגיאה", MessageBoxButton.OK, MessageBoxImage.Error); }
                MaterialDesignThemes.Wpf.DialogHost.CloseDialogCommand.Execute(null, null);
                OpenHostWin(Host.PersonalInfo.Id);
            }
            else if (State == "upd")
            {
                try { bl.UpdHost(Host); }
                catch (MissingMemberException ex) { MessageBox.Show(ex.Message, "שגיאה", MessageBoxButton.OK, MessageBoxImage.Error); }

                MaterialDesignThemes.Wpf.DialogHost.CloseDialogCommand.Execute(null, null);
                OpenHostWin(Host.PersonalInfo.Id);
            }
        }