public static bool AddCargo(Cargo cargo)
        {
            try
            {
                openConection();
                DataValidation dataValidation = new DataValidation();

                string name             = cargo.Name;
                int    cost             = cargo.Cost;
                int    weight           = cargo.Weight;
                int    volume           = cargo.Volume;
                string uploadDate       = cargo.UploadDate;
                string trailerType      = cargo.TrailerType;
                string status           = cargo.Status;
                string downloadLocation = cargo.DownloadLocation;
                string placeOfDischarge = cargo.PlaceOfDischarge;
                int    distance         = cargo.Distance;

                if (dataValidation.CheckEmptyFields(name, uploadDate, trailerType, status, downloadLocation, placeOfDischarge) &&
                    dataValidation.CheckCost(cost) && dataValidation.CheckDistance(distance) && dataValidation.CheckVolume(volume) &&
                    dataValidation.CheckWeight(weight)) // проверка данных
                {
                    SqlCommand sqlCommand = new SqlCommand(@"INSERT INTO Cargos (
                            Name, Cost, Weight, Volume, TrailerType, UploadDate, Status, DownloadLocation, PlaceOfDischarge,Distance)
                            VALUES(@name, @cost, @weight, @volume, @trailerType, @uploadDate, @status,@downloadLocation,@placeOfDischarge,
                            @distance)",
                                                           CatalogContext.sqlConnection);
                    sqlCommand.Parameters.AddWithValue("Name", name);
                    sqlCommand.Parameters.AddWithValue("Cost", cost);
                    sqlCommand.Parameters.AddWithValue("Weight", weight);
                    sqlCommand.Parameters.AddWithValue("Volume", volume);
                    sqlCommand.Parameters.AddWithValue("TrailerType", trailerType);
                    sqlCommand.Parameters.AddWithValue("UploadDate", uploadDate);
                    sqlCommand.Parameters.AddWithValue("Status", status);
                    sqlCommand.Parameters.AddWithValue("DownloadLocation", downloadLocation);
                    sqlCommand.Parameters.AddWithValue("PlaceOfDischarge", placeOfDischarge);
                    sqlCommand.Parameters.AddWithValue("Distance", distance);

                    sqlCommand.ExecuteNonQuery();
                    closeConection();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            finally
            {
                closeConection();
            }
        }
        //Регистрация пользователя и занесение данных в БД
        public void RegistrationOfUsers(object sender, EventArgs e)
        {
            DataValidation dv = new DataValidation();

            if (dv.CheckEmptyFields(textBox1.Text, textBox2.Text, textBox3.Text))
            {
                if (dv.CheckLenghtLogin(textBox1.Text))
                {
                    if (dv.CheckLenghtPassword(textBox2.Text))
                    {
                        if (dv.CheckPasswordMatch(textBox2.Text, textBox3.Text))
                        {
                            if (!UsersDB.CheckUserInDB(textBox1.Text))
                            {
                                UsersDB.AddUser(textBox1.Text, textBox2.Text);
                                MessageBox.Show("Регистрация прошла успешно");
                                form.Visible = true;
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Пользователь с таким логином уже существует. Введите другой логин", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Пароли не совпадают", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            textBox2.Clear();
                            textBox3.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Пароль содержит недоступное количество символов", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        textBox2.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Логин содержит недоступное количество символов", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBox1.Clear();
                }
            }
            else
            {
                MessageBox.Show("Одно из полей пустое", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void DeleteFavouritesCargo(object sender, EventArgs e)
        {
            DataValidation dv   = new DataValidation();
            int            line = dataGridView1.CurrentRow.Index;
            int            id   = Convert.ToInt32(dataGridView1.Rows[line].Cells[0].Value);

            string cargoId = UsersDB.SelectCargoId(userForm.Login);
            int    n       = cargoId.IndexOf(id.ToString());

            cargoId = cargoId.Remove(n, id.ToString().Length);

            if (!dv.CheckStringForDigits(cargoId))
            {
                cargoId = "";
            }
            UsersDB.UpdateFavourites(cargoId, userForm.Login);
        }