Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string a = dateTimePicker1.Text;
            string d = dateTimePicker2.Text;
            int    s = int.Parse(a[0].ToString() + a[1].ToString());
            int    t = int.Parse(d[0].ToString() + d[1].ToString());

            listView2.Items.Clear();
            List <Contracts> contr = Contracts.GetContracts();

            for (int i = 0; i < contr.Count; i++)
            {
                int q = int.Parse(contr[i].DataOpen[0].ToString() + contr[i].DataOpen[1].ToString());
                if (q > s && q < t)
                {
                    string[] array = new string[3];
                    array[0] = contr[i].Id.ToString();
                    Users g = Users.GetUsers(contr[i].IdUser);
                    array[1] = contr[i].DataOpen;

                    Cars k = Cars.GetCar(contr[i].IdCar);
                    array[2] = k.Vin;


                    listView2.Items.Add(new ListViewItem(array));
                }
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 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;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void carsView_MouseClick(object sender, MouseEventArgs e)
 {
     if (!admin)
     {
         string selected = carsView.SelectedItems[0].Text;
         Form   AddCars  = new AddCars(this, Cars.GetCar(int.Parse(selected)), s);
         AddCars.Owner = this;
         AddCars.ShowDialog();
         updateListView();
     }
 }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
0
        public AllContracts()
        {
            InitializeComponent();
            listView1.Items.Clear();
            List <Contracts> v = Contracts.GetContracts();

            for (int i = 0; i < v.Count; i++)
            {
                string[] array = new string[7];
                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;
                array[6] = v[i].DataClose;

                listView1.Items.Add(new ListViewItem(array));
            }
        }
Ejemplo n.º 7
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));
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (c != null)
            {
                if (
                    !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) &&
                    !string.IsNullOrEmpty(textBox3.Text) && !string.IsNullOrWhiteSpace(textBox3.Text) &&

                    !string.IsNullOrEmpty(comboBox1.Text) && !string.IsNullOrWhiteSpace(comboBox1.Text) &&
                    !string.IsNullOrEmpty(comboBox2.Text) && !string.IsNullOrWhiteSpace(comboBox2.Text))

                {
                    Users     cl = Users.GetUsers(comboBox1.Text);
                    Cars      c2 = Cars.GetCar(comboBox2.Text);
                    Contracts m  = new Contracts(c.Id, cl.Id, dateTimePicker1.Text.ToString(), c2.Id, textBox2.Text.ToString(), textBox3.Text.ToString(), DateTime.Today.ToString());
                    Contracts.Update(pt, m);
                    Close();
                }
                else
                {
                    MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
                }
            }
            else
            {
                if (int.Parse(textBox3.Text) >= int.Parse(textBox2.Text))
                {
                    MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
                }



                else
                {
                    if (
                        !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) &&
                        !string.IsNullOrEmpty(textBox3.Text) && !string.IsNullOrWhiteSpace(textBox3.Text) &&

                        !string.IsNullOrEmpty(comboBox1.Text) && !string.IsNullOrWhiteSpace(comboBox1.Text) &&
                        !string.IsNullOrEmpty(comboBox2.Text) && !string.IsNullOrWhiteSpace(comboBox2.Text))
                    {
                        try
                        {
                            Users cl = Users.GetUsers(comboBox1.Text);
                            Cars  c2 = Cars.GetCar(comboBox2.Text);
                            Contracts.AddContracts(pt, cl.Id, dateTimePicker1.Text.ToString(), c2.Id, textBox2.Text.ToString(), textBox3.Text.ToString());

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


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