Esempio n. 1
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();
            }
        }
Esempio n. 2
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();
            }
        }