Example #1
0
        private void BaddDepCln_Click(object sender, RoutedEventArgs e)
        {
            if (LvClients.SelectedItems.Count > 0)
            {
                string client      = LvClients.SelectedItem.ToString();
                int    k           = client.IndexOf('.');
                int    clientId    = Int32.Parse(client.Substring(0, k));
                var    clientsSel2 = bd.Clients.FirstOrDefault(p => p.Id == clientId);

                var depCln = new DepositClient();

                depCln.Client           = clientsSel2;
                depCln.DateOfEnrollment = DateTime.Today;

                AddDepToClnWindow add = new AddDepToClnWindow(depCln);
                add.Owner = this;
                var result = add.ShowDialog();
                if (result == true)
                {
                    try
                    {
                        bd.DepositClients.Add(depCln);
                        bd.SaveChanges();
                        add.Close();
                    }
                    catch (Exception h)
                    {
                        MessageBox.Show("Такой вклад у клиента уже открыт");
                    }
                }
                else
                {
                    add.Close();
                }

                UpdatingInformationClient();
            }
            else
            {
                MessageBox.Show("Выделите клиента в списке");
            }
        }
Example #2
0
        public AddDepToClnWindow(DepositClient depCln)
        {
            InitializeComponent();
            this.depCln      = depCln;
            bd               = new BankContext();
            grid.DataContext = depCln;



            var depList = bd.Deposits.Select(p => new
            {
                Id   = p.Id,
                Name = p.Name
            }).ToList();


            List <string> liststr = new List <string>();

            foreach (var item in depList)
            {
                liststr.Add(item.Name.ToString());
                CbDepToCln.ItemsSource = liststr;
            }
        }