Пример #1
0
 private void ShowScheduledContracts(Schedule schedule)
 {
     foreach (var scheduleDetail in schedule.ScheduleDetails)
     {
         if (ScheduledContracts.All(x => x.ContractNo != scheduleDetail.ContractNo))
         {
             ScheduledContracts.Add(scheduleDetail.Contract);
         }
     }
 }
Пример #2
0
        public void FindCustomerContracts()
        {
            if (Customer == null)
            {
                return;
            }

            try
            {
                using (IUnitOfWork unit = new UnitOfWork())
                {
                    var contracts =
                        ((ContractsRepository)unit.Contracts).CustomerActiveContracts(Customer.CustomerId);


                    if (contracts.Count() == 1)
                    {
                        ScheduledContracts.Clear();
                        ScheduledContracts.Add(contracts.First());
                    }
                    else if (contracts.Count() > 1)
                    {
                        SelectContractsDialog dialog = new SelectContractsDialog(Customer.CustomerId);
                        dialog.ShowDialog();
                        if (dialog.DialogResult == true)
                        {
                            SelectContractsController controller = dialog.DataContext as SelectContractsController;
                            if (controller != null)
                            {
                                ScheduledContracts.Clear();
                                foreach (var contract in controller.SelectedContracts)
                                {
                                    ScheduledContracts.Add(contract);
                                }
                            }
                        }
                    }
                    else
                    {
                        Helper.ShowMessage(Properties.Resources.ScheduleView_CustomerAlreadyScheduled);
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.LogShowError(ex);
            }
        }