Пример #1
0
        private void findCarsButton_Click(object sender, EventArgs e)
        {
            label5.Text = "";
            if (textBox2.Text != null && textBox2.Text != "")
            {
                Users       f = Users.GetUsers(textBox2.Text);
                List <Cars> q = Cars.GetCarr(f.Id);
                listView7.Items.Clear();
                if (q.Count == 0)
                {
                    noDataLabel.Text = "Ничего не найдено";
                }
                for (int i = 0; i < q.Count; i++)
                {
                    string[] array = new string[3];

                    array[0] = q[i].Id.ToString();

                    array[1] = q[i].Vin;
                    List <String> m = Cars.GetModel(q[i].IdModel);
                    array[2] = m[0];
                    listView7.Items.Add(new ListViewItem(array));
                }
            }
        }
Пример #2
0
        private void allContractsButton_Click(object sender, EventArgs e)
        {
            noDataLabel.Text = "";
            if (contractsBox.Text != null && contractsBox.Text != "")
            {
                Users f = Users.GetUsers(contractsBox.Text);

                List <Contracts> q = Contracts.GetContracts(f.Id);
                openContractsView.Items.Clear();
                if (q.Count == 0)
                {
                    noDataLabel.Text = "Ничего не найдено";
                }
                for (int i = 0; i < q.Count; i++)
                {
                    string[] array = new string[3];

                    array[0] = q[i].Id.ToString();

                    Cars k = Cars.GetCar(q[i].IdCar);
                    array[1] = k.Vin;
                    List <String> m = Cars.GetModel(k.IdModel);
                    array[2] = m[0];
                    openContractsView.Items.Add(new ListViewItem(array));
                }
            }
        }
Пример #3
0
        private void openContractsButton_Click(object sender, EventArgs e)
        {
            noDataLabel.Text = "";
            if (contractsBox.Text != null && contractsBox.Text != "")
            {
                Users            f = Users.GetUsers(contractsBox.Text);
                List <Contracts> q = Contracts.GetContracts(f.Id);
                openContractsView.Items.Clear();

                for (int i = 0; i < q.Count; i++)
                {
                    string[] array = new string[3];
                    if (q[i].DataClose == null)
                    {
                        array[0] = q[i].Id.ToString();

                        Cars k = Cars.GetCar(q[i].IdCar);
                        array[1] = k.Vin;
                        array[2] = Cars.GetModel(k.Id).ToString();
                        openContractsView.Items.Add(new ListViewItem(array));
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
Пример #4
0
        public AddCars(Main m, Cars c, string pt)
        {
            InitializeComponent();
            button3.Visible = false;
            List <Clients> list = Clients.GetAllClients();

            for (int i = 0; i < list.Count; i++)
            {
                comboBox1.Items.Add(list[i].surname);
            }
            List <Model> list2 = Cars.GetModels();

            for (int i = 0; i < list2.Count; i++)
            {
                comboBox2.Items.Add(list2[i].name);
            }

            this.m  = m;
            this.c  = c;
            this.pt = pt;;
            if (c != null)
            {
                Clients v = Clients.GetClient(c.IdClient);
                comboBox1.Text = v.surname;
                List <String> a = Cars.GetModel(c.IdModel);
                comboBox2.Text  = a[0];
                textBox1.Text   = c.Vin;
                textBox2.Text   = c.Color;
                textBox3.Text   = c.IssueDate;
                textBox4.Text   = c.Milleage;
                textBox5.Text   = c.Transmission;
                button3.Visible = true;
            }
        }
Пример #5
0
        public void updateListView()
        {
            historyView.Items.Clear();
            List <Log> l = Log.GetAllLog();

            for (int i = 0; i < l.Count; i++)
            {
                string[] array = new string[5];
                array[0] = l[i].IdWrite.ToString();
                array[1] = l[i].LastNameUser;
                array[2] = l[i].Act;
                array[3] = l[i].TableAct;
                array[4] = l[i].DateAct;
                historyView.Items.Add(new ListViewItem(array));
            }

            usersView.Items.Clear();
            List <Users> u = Users.GetAllUsers();

            for (int i = 0; i < u.Count; i++)
            {
                string[] array = new string[7];
                array[0] = u[i].Id.ToString();
                if (u[i].IdUserRole == 1)
                {
                    array[1] = "админ";
                }
                else
                {
                    array[1] = "диллер";
                }

                array[2] = u[i].Surname;
                array[3] = u[i].Name;
                array[4] = u[i].Patronymic;
                array[5] = u[i].Address;
                array[6] = u[i].Phone;

                usersView.Items.Add(new ListViewItem(array));
            }
            clientsView.Items.Clear();
            List <Clients> a = Clients.GetAllClients();

            for (int i = 0; i < a.Count; i++)
            {
                string[] array = new string[6];
                array[0] = a[i].Id.ToString();
                array[1] = a[i].surname;
                array[2] = a[i].Name;
                array[3] = a[i].Patronymic;
                array[4] = a[i].Address;
                array[5] = a[i].Phone;
                clientsView.Items.Add(new ListViewItem(array));
            }
            contractsView.Items.Clear();
            List <Contracts> v = Contracts.GetContracts();

            for (int i = 0; i < v.Count; i++)
            {
                string[] array = new string[6];
                if (v[i].DataClose == null)
                {
                    array[0] = v[i].Id.ToString();
                    Users g = Users.GetUsers(v[i].IdUser);
                    array[2] = v[i].DataOpen;
                    array[1] = g.Surname;
                    Cars k = Cars.GetCar(v[i].IdCar);
                    array[3] = k.Vin;
                    array[4] = v[i].Cost;
                    array[5] = v[i].Commission;
                }
                else
                {
                    continue;
                }


                contractsView.Items.Add(new ListViewItem(array));
            }
            carsView.Items.Clear();
            List <Cars> d = Cars.GetCars();

            for (int i = 0; i < d.Count; i++)
            {
                string[] array = new string[8];
                array[0] = d[i].Id.ToString();
                Clients c = Clients.GetClient(d[i].IdClient);
                array[1] = c.surname;
                List <String> m = Cars.GetModel(d[i].IdModel);
                array[2] = m[0];
                array[4] = d[i].Color;
                array[3] = d[i].Vin;
                array[5] = d[i].IssueDate;
                array[6] = d[i].Milleage;
                array[7] = d[i].Transmission;
                carsView.Items.Add(new ListViewItem(array));
            }
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (c != null)
            {
                if (!string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox1.Text) &&
                    !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) &&
                    !string.IsNullOrEmpty(textBox3.Text) && !string.IsNullOrWhiteSpace(textBox3.Text) &&
                    !string.IsNullOrEmpty(textBox4.Text) && !string.IsNullOrWhiteSpace(textBox4.Text) &&
                    !string.IsNullOrEmpty(textBox5.Text) && !string.IsNullOrWhiteSpace(textBox5.Text) &&
                    !string.IsNullOrEmpty(comboBox1.Text) && !string.IsNullOrWhiteSpace(comboBox1.Text) &&
                    !string.IsNullOrEmpty(comboBox2.Text) && !string.IsNullOrWhiteSpace(comboBox2.Text))

                {
                    try
                    {
                        Clients cl = Clients.GetClient(comboBox1.Text);
                        Model   c2 = Cars.GetModel(comboBox2.Text);
                        Cars    m  = new Cars(c.Id, cl.Id, c2.id, textBox2.Text.ToString(), textBox1.Text.ToString(), textBox3.Text.ToString(), textBox4.Text.ToString(), textBox5.Text.ToString());
                        Cars.Update(pt, m);
                        Close();
                    }
                    catch
                    {
                        MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox1.Text) &&
                    !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) &&
                    !string.IsNullOrEmpty(textBox3.Text) && !string.IsNullOrWhiteSpace(textBox3.Text) &&
                    !string.IsNullOrEmpty(textBox4.Text) && !string.IsNullOrWhiteSpace(textBox4.Text) &&
                    !string.IsNullOrEmpty(textBox5.Text) && !string.IsNullOrWhiteSpace(textBox5.Text) &&
                    !string.IsNullOrEmpty(comboBox1.Text) && !string.IsNullOrWhiteSpace(comboBox1.Text) &&
                    !string.IsNullOrEmpty(comboBox2.Text) && !string.IsNullOrWhiteSpace(comboBox2.Text))

                {
                    try
                    {
                        Clients cl = Clients.GetClient(comboBox1.Text);
                        Model   c2 = Cars.GetModel(comboBox2.Text);
                        Cars.AddCar(pt, cl.Id, c2.id, textBox2.Text.ToString(), textBox1.Text.ToString(), textBox3.Text.ToString(), textBox4.Text.ToString(), textBox5.Text.ToString());

                        Close();
                    }
                    catch
                    {
                        MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
                    }
                }


                else
                {
                    MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
                }
            }
        }