public ManagerClientsForm()
        {
            InitializeComponent();
            ControlClients CtrlClients = new ControlClients();

            comboBoxClients.DataSource = CtrlClients.ClientsToList(CtrlClients.Clients);
        }
Beispiel #2
0
        public void AddClientToDB(ControlClients CtrlClients, int ClientId, string LastName, string FirstName, string SecondName, string PhoneNumber, string Email)
        {
            Connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\Visual Studio 2015\Projects\EduCentre\EdCentre.accdb;
Persist Security Info=False;";

            try
            {
                Connection.Open();
                OleDbCommand CommandInsert = new OleDbCommand();
                CommandInsert.Connection  = Connection;
                CommandInsert.CommandText = "INSERT INTO clients(last_name, first_name, second_name, phone_number, email) values('" + LastName + "', '" + FirstName + "', '" + SecondName + "', '" + PhoneNumber + "', '" + Email + "')";
                CommandInsert.ExecuteNonQuery();
                Client NewClient = new Client(ClientId, LastName, FirstName, SecondName, PhoneNumber, Email);
                CtrlClients.Clients.Add(NewClient);
                MessageBox.Show("Клиент добавлен");
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex);
            }

            Connection.Close();
        }