Exemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            var addClientForm = new AddClientForm();

            addClientForm.ShowDialog();
            MainFormUtils.SetRoot(treeViewClients, _clientService.GetRootClients());
        }
Exemplo n.º 2
0
        // Добавление
        private void tbAdd_Click(object sender, EventArgs e)
        {
            AddClientForm ClientTab = new AddClientForm();
            DialogResult  result    = ClientTab.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            client client = new client();

            client.fio = ClientTab.textBox_fio.Text;

            var s = ClientTab.textBox_pas.Text;

            client.pass = Convert.ToInt32(s);
            client.born = ClientTab.dateTimePicker_born.Value;

            var id = ClientTab.textBox_id.Text;

            client.idclient = Convert.ToInt32(id);
            dbcontex.client.Add(client);
            dbcontex.SaveChanges();

            MessageBox.Show("Новый объект добавлен");
        }
Exemplo n.º 3
0
        // Изменение
        private void tbEdit_Click(object sender, EventArgs e)
        {
            int index = getSelectedRow(dataGridView1);

            if (index != -1)
            {
                int  id        = 0;
                bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }

                client client = dbcontex.client.Where(i => i.idclient == id).FirstOrDefault();
                if (client != null)
                {
                    AddClientForm ClientTab = new AddClientForm();

                    ClientTab.textBox_fio.Text         = client.fio;
                    ClientTab.textBox_pas.Text         = client.pass.Value.ToString();
                    ClientTab.dateTimePicker_born.Text = client.born.ToString();
                    ClientTab.textBox_id.Text          = client.idclient.ToString();
                    DialogResult result = ClientTab.ShowDialog(this);

                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }

                    client.fio = ClientTab.textBox_fio.Text;

                    var s = ClientTab.textBox_pas.Text;
                    client.pass = Convert.ToInt32(s);
                    client.born = ClientTab.dateTimePicker_born.Value;

                    var idClient = ClientTab.textBox_id.Text;
                    client.idclient = Convert.ToInt32(idClient);

                    dbcontex.SaveChanges();
                    dataGridView1.Refresh(); // обновляем грид
                    MessageBox.Show("Объект обновлен");
                }
            }
        }
Exemplo n.º 4
0
 private void btn_OrderClient_Click(object sender, EventArgs e)
 {
     client_form.ShowDialog();
     textBox_OrderClient.Text = order.client.ToString();
 }