Example #1
0
        public AddContract(Main m, Contracts c, string pt)
        {
            InitializeComponent();
            label6.Visible  = false;
            button3.Visible = false;
            List <Users> list = Users.GetAllUsers();

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].IdUserRole == 2)
                {
                    comboBox1.Items.Add(list[i].Surname);
                }
            }
            List <Contracts> contr = Contracts.GetContracts();
            List <Cars>      list2 = Cars.GetCars();

            for (int i = 0; i < list2.Count; i++)
            {
                bool a = false;
                for (int t = 0; t < contr.Count; t++)
                {
                    if (contr[t].IdCar == list2[i].Id)
                    {
                        a = true;
                    }
                }
                if (!a)
                {
                    comboBox2.Items.Add(list2[i].Vin);
                }
            }

            this.m  = m;
            this.c  = c;
            this.pt = pt;;
            if (c != null)
            {
                button1.Text = "Завершить контракт";
                Users v = Users.GetUsers(c.IdUser);
                if (v.IdUserRole == 2)
                {
                    comboBox1.Text = v.Surname;
                }
                Cars a = Cars.GetCar(c.IdCar);
                comboBox2.Text = a.Vin;

                textBox2.Text   = c.Cost;
                textBox3.Text   = c.Commission;
                button3.Visible = true;
                label6.Visible  = true;
            }
        }
Example #2
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));
            }
        }