예제 #1
0
        private void InitializeClientList()
        {
            _clientItems = new List<TreeNode>();

            using (var db = new AwesomeContext())
            {
                db.Clients.OrderBy(x => x.Name).ToList().ForEach(x =>
                {
                    var item = new TreeNode()
                    {
                        Text = x.Name
                    };
                    //x.Projects = db.Projects.Where(y => y.Client == x);
                    if (x.Projects != null)
                    {
                        foreach (Project proj in x.Projects)
                        {
                            item.Nodes.Add(new TreeNode()
                            {
                                Text = proj.Name
                            });
                        }
                    }
                    _clientItems.Add(item);
                });
            }

            tvListClients.Nodes.Clear();
            tvListClients.Nodes.AddRange(_clientItems.ToArray());
        }
예제 #2
0
        private void addProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var db = new AwesomeContext())
            {
                var selectedClient = db.Clients.SingleOrDefault(x => x.Name == tvListClients.SelectedNode.Text);

                var project = new Project
                {
                    Finished = false,
                    Client = selectedClient
                };

                var addProjectForm = new AddProjectForm(project, db)
                {
                    Text = Resources.CreateNewProjectDialogText
                };

                if (addProjectForm.ShowDialog() == DialogResult.OK)
                {

                    db.Projects.Add(project);
                    db.SaveChanges();
                    InitializeClientList();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Edit a Client entry
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvListClients_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            lock (_lock)
            {
                using (var db = new AwesomeContext())
                {

                    var selectedItem = ((TreeView)sender).SelectedNode.Text;// SelectedItems[0].Text;

                    var client = db.Clients.SingleOrDefault(x => x.Name == selectedItem);
                    var editClientForm = new AddClientFrm(client)
                    {
                        Text = Resources.EditClientDialogText
                    };

                    if (editClientForm.ShowDialog() == DialogResult.OK)
                    {
                        db.SaveChanges();
                    }
                }
                InitializeClientList();
            }
        }
예제 #4
0
        /// <summary>
        /// Enter a new Client entry
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newClientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var client = new Client();
            var addClientForm = new AddClientFrm(client)
                {
                    Text = Resources.CreateNewClientDialogText
                };

            if (addClientForm.ShowDialog() == DialogResult.OK)
            {
                using (var db = new AwesomeContext())
                {
                    db.Clients.Add(client);
                    db.SaveChanges();
                }
                InitializeClientList();
            }
        }