コード例 #1
0
        public void AddButton_Click(object sender, EventArgs e)
        {
            ClientForm f2     = new ClientForm();
            Client     client = new Client();

            f2.SetClient(client);

            f2.ShowDialog();

            db.Clients.Add(client);
            db.SaveChanges();
            ClientListBox.Items.Add(client);
        }
コード例 #2
0
        public void EditButton_Click(object sender, EventArgs e)
        {
            int clientindex = ClientListBox.SelectedIndex;

            if (clientindex == -1)
            {
                return;
            }

            ClientForm f2     = new ClientForm();
            Client     client = (Client)ClientListBox.Items[clientindex];

            f2.SetClient(client);

            f2.ShowDialog();
            if (f2.SaveClient == true)
            {
                db.SaveChanges();
                ClientListBox.Items[clientindex] = client;
            }
        }