private void ButtonDashboard_Click(object sender, RoutedEventArgs e)
        {
            TextblockPanelName.Text = "Dashboard";

            RoleCache.GetInstance().Clear();
            EmployeeCache.GetInstance().Clear();
            ResourceCache.GetInstance().Clear();
            CustomerCache.GetInstance().Clear();
            ProcessCache.GetInstance().Clear();
            ProjectCache.GetInstance().Clear();

            List <Resource> recs = ResourceCache.GetInstance().Resources;

            recs = ResourceCache.GetInstance().UpdateAllQSizes();
            recs = recs.OrderByDescending(r => r.QSize).ToList <Resource>();
            var emps = EmployeeCache.GetInstance().Employees;

            emps        = EmployeeCache.GetInstance().UpdateAllQSizes();
            emps        = emps.OrderByDescending(e => e.QSize).ToList <Employee>();
            DataContext = new DashboardViewModel
            {
                Resources        = new ObservableCollection <Resource>(recs),
                SelectedResource = recs[0],
                Employees        = new ObservableCollection <Employee>(emps),
                SelectedEmployee = emps[0]
            };
        }
        private void ProjectViewNewProjectClickHandler(ProjectsViewModel viewModel)
        {
            TextblockPanelName.Text = "Create New Project";

            RoleCache.GetInstance().Clear();
            EmployeeCache.GetInstance().Clear();
            ResourceCache.GetInstance().Clear();
            CustomerCache.GetInstance().Clear();
            ProcessCache.GetInstance().Clear();
            ProjectCache.GetInstance().Clear();
            var resources = ResourceCache.GetInstance().Resources;

            resources = ResourceCache.GetInstance().UpdateAllQSizes();

            DataContext = new AddEditProjectViewModel
            {
                Project = new Project
                {
                    Id          = 0,
                    Processes   = new List <Process>(),
                    StartDate   = DateTimeOffset.UtcNow,
                    PoDate      = DateTimeOffset.UtcNow,
                    Quantity    = 1,
                    OrderStatus = Project.ProjectOrderStatus.WaitingQuote,
                },
                BackClickedHandler = AddEditProjectViewBackClickHandler,
                Customers          = CustomerCache.GetInstance().Customers,
                Processes          = new ObservableCollection <Process>(new List <Process>()),
                Resources          = resources.OrderByDescending(r => r.QSize).ToList <Resource>(),
                Employees          = EmployeeCache.GetInstance().Employees
            };
        }
예제 #3
0
 public Customer SyncCustomer(Customer customer)
 {
     if (GetCustomerByName(customer.Name) == null)
     {
         CustomerCache.GetInstance().InsertNewCustomer(customer);
     }
     return(GetCustomerByName(customer.Name));
 }
예제 #4
0
        public string[] GetNamesOfCustomers()
        {
            List <string> nameList = new List <string>();

            foreach (Customer customer in CustomerCache.GetInstance().Customers)
            {
                nameList.Add(customer.Name);
            }
            return(nameList.ToArray());
        }
예제 #5
0
 public void Refresh()
 {
     CustomerCache.GetInstance().Clear();
     EmployeeCache.GetInstance().Clear();
     Customers = new ObservableCollection <Customer>(CustomerCache.GetInstance().Customers);
     Employees = new ObservableCollection <Employee>(EmployeeCache.GetInstance().Employees);
     ListViewCustomers.ItemsSource       = Customers;
     ComboboxCustomerManager.ItemsSource = Employees;
     ListViewCustomers.SelectedItem      = GetFirstCustomer();
 }
예제 #6
0
 private void SaveCustomer(Customer itemToSave)
 {
     if (itemToSave.Id > 0)
     {
         CustomerCache.GetInstance().Update(itemToSave);
     }
     else
     {
         CustomerCache.GetInstance().Insert(itemToSave);
     }
     Customers = new ObservableCollection <Customer>(CustomerCache.GetInstance().Customers);
 }
예제 #7
0
 public void UpdateCustomerByID(Customer changedCustomer)
 {
     if (changedCustomer.ID < 0)
     {
         CustomerCache.GetInstance().InsertNewCustomer(changedCustomer);
     }
     else
     {
         CustomerCache.GetInstance().UpdateCustomer(changedCustomer);
         //force cache reload on next access
         CustomerCache.GetInstance().Clear();
     }
 }
예제 #8
0
        public void DeleteCustomer(int selectedCustomerID)
        {
            CustomerCache.GetInstance().DeleteCustomer(selectedCustomerID);
            //>>replace the deleted customer's id with empty customer id
            //1. find the empty customer
            Customer defaultCustomer = GetCustomerByName(string.Empty);

            if (defaultCustomer != null)
            {
                //use the id to replace deleted Customer's ID in all transactions.
                (new TransactionManager()).ReplaceCustomer(selectedCustomerID, defaultCustomer.ID);
            }

            //force cache reload on next access
            CustomerCache.GetInstance().Clear();
        }
        private void ProjectViewOpenProectClickHandler(ProjectsViewModel viewModel)
        {
            TextblockPanelName.Text = "Project Details";
            RoleCache.GetInstance().Clear();
            EmployeeCache.GetInstance().Clear();
            ResourceCache.GetInstance().Clear();
            CustomerCache.GetInstance().Clear();
            ProcessCache.GetInstance().Clear();
            ProjectCache.GetInstance().Clear();
            var resources = ResourceCache.GetInstance().Resources;

            resources = ResourceCache.GetInstance().UpdateAllQSizes();

            DataContext = new AddEditProjectViewModel
            {
                Project            = viewModel.SelectedProject,
                BackClickedHandler = AddEditProjectViewBackClickHandler,
                Customers          = CustomerCache.GetInstance().Customers,
                Processes          = new ObservableCollection <Process>(viewModel.SelectedProject.Processes),
                Resources          = resources.OrderByDescending(r => r.QSize).ToList <Resource>(),
                Employees          = EmployeeCache.GetInstance().Employees
            };
        }
예제 #10
0
 public List <Customer> GetAllCustomers()
 {
     return(CustomerCache.GetInstance().Customers);
 }
예제 #11
0
 internal void RefreshCache()
 {
     CustomerCache.GetInstance().Clear();
     CustomerCache.GetInstance();
 }
예제 #12
0
 public double GetPendingAmountTill(int customerID, DateTime tillDate)
 {
     return(CustomerCache.GetInstance().GetPendingAmountBefore(customerID, tillDate));
 }
예제 #13
0
 public Customer GetCustomerByName(string name)
 {
     return(CustomerCache.GetInstance().GetCustomerByName(name.Trim().ToLower()));
 }
예제 #14
0
 public Customer GetCustomerByID(int ID)
 {
     return(CustomerCache.GetInstance().GetCustomerById(ID));
 }
예제 #15
0
 private void DeleteSelectedCustomer()
 {
     CustomerCache.GetInstance().Delete(ListViewCustomers.SelectedItem as Customer);
     Customers = new ObservableCollection <Customer>(CustomerCache.GetInstance().Customers);
 }
예제 #16
0
 public Customer GetCustomerByName(string name)
 {
     return(CustomerCache.GetInstance().GetCustomerByName(name));
 }