Beispiel #1
0
        public static void Update(string pt, Cars c)
        {
            string        connectionStr = @"Data Source=DROGPC;Initial Catalog=DrogsMtrs;Integrated Security=True";
            SqlConnection sql           = new SqlConnection(connectionStr);

            sql.Open();
            SqlCommand command = new SqlCommand("update [Cars] SET IdClient=@IdClien,IdModel = @IdModel,Vin=@Vin,Color=@Color,IssueDate=@IssueDate,Milleage=@Milleage,Transmission=@Transmission where id = @ID", sql);

            command.Parameters.AddWithValue("@IdClient", c.IdClient);
            command.Parameters.AddWithValue("@IdModel", c.IdModel);
            command.Parameters.AddWithValue("@Vin", c.Vin);
            command.Parameters.AddWithValue("@Color", c.Color);
            command.Parameters.AddWithValue("@IssueDate", c.IssueDate);
            command.Parameters.AddWithValue("@Milleage", c.Milleage);
            command.Parameters.AddWithValue("@Transmission", c.Transmission);
            command.Parameters.AddWithValue("@ID", c.Id);
            bool res = command.ExecuteNonQuery() == 1;

            sql.Close();
            Log.AddLog(pt, "Изменение данных машины " + c.Vin, "Машины", DateTime.Now.ToString());
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox1.Text) &&
                !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox2.Text))
            {
                try
                {
                    Cars.AddModel(pt, textBox1.Text, textBox2.Text);
                }
                finally
                {
                    Close();
                }
            }



            else
            {
                MessageBox.Show("Вы ввели некорректные данные, попробуйте еще раз)", "Ошибка", MessageBoxButtons.OK);
            }
        }
Beispiel #4
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));
            }
        }
Beispiel #5
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);
                }
            }
        }
Beispiel #6
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);
                    }
                }
            }
        }