Exemple #1
0
        //================== ПРОВАЙДЕР ==================
        private void AddProviderButton_Click(object sender, EventArgs e)
        {
            var form = new AddProvider();

            form.Text = "Добавление провайдера";
            if (form.ShowDialog() == DialogResult.OK)
            {
                var conn = new SqlConnection(connectionString);
                conn.Open();

                var request = "INSERT INTO " + ProviderTableName + "(Name_Provider, Rating)" + " VALUES "
                              + "('" + form.ProviderNameText.Text + "', '" + form.RatingText.Text + "')";
                var com = new SqlCommand(request, conn);
                com.ExecuteNonQuery();
                conn.Close();

                updateProviderDGW();
            }
        }
Exemple #2
0
        private void EditProviderButton_Click(object sender, EventArgs e)
        {
            var mas      = ProviderDGW.SelectedRows;
            var Candidat = mas[0].Cells[0].FormattedValue.ToString();
            var form     = new AddProvider();

            var conn = new SqlConnection(connectionString);

            conn.Open();
            var req  = "SELECT Name_Provider FROM Varpaev_ProviderTable WHERE Id_Provider = " + Candidat + "";
            var com  = new SqlCommand(req, conn);
            var last = com.ExecuteScalar();

            form.ProviderNameText.Text = last.ToString();

            req  = "SELECT Rating FROM Varpaev_ProviderTable WHERE Id_Provider = " + Candidat + "";
            com  = new SqlCommand(req, conn);
            last = com.ExecuteScalar();
            form.RatingText.Text = last.ToString();

            conn.Close();

            if (form.ShowDialog() == DialogResult.OK)
            {
                conn = new SqlConnection(connectionString);
                conn.Open();

                var request = "UPDATE " + ProviderTableName + " SET Varpaev_ProviderTable.Name_Provider='"
                              + form.ProviderNameText.Text + "', " + "Varpaev_ProviderTable.Rating= " + form.RatingText.Text
                              + " WHERE Id_Provider = " + Candidat + "";

                com = new SqlCommand(request, conn);
                com.ExecuteNonQuery();
                conn.Close();

                updateProviderDGW();
                updateBookDGW();
            }
        }