Exemplo n.º 1
0
        private void DeleteComputerButton_Click(object sender, EventArgs e)
        {
            string queryString      = "DELETE FROM dbo.PC_O WHERE Id_WorkPlace = '{0}'";
            string queryStateString = "DELETE FROM dbo.State WHERE Id_WorkPlace = '{0}'";
            string queryMoneyString = "DELETE FROM dbo.workPlace_Receips WHERE Id_WorkPlace = '{0}'";

            SqlConnection sqlConnection = new SqlConnection(connectionString);

            var ID = ComputersDataGridView.Rows[ComputersDataGridView.SelectedCells[0].RowIndex].Cells[0].Value;

            string deleteFormat      = string.Format(queryString, ID);
            string deleteStateFormat = string.Format(queryStateString, ID);
            string deleteMoneyFormat = string.Format(queryMoneyString, ID);

            Sure_Form sure_Form = new Sure_Form();

            if (sure_Form.ShowDialog() == DialogResult.Yes)
            {
                sqlConnection.Open();

                SqlCommand deleteCommand = new SqlCommand(deleteFormat, sqlConnection);

                deleteCommand.ExecuteNonQuery();

                sqlConnection.Close();

                sqlConnection.Open();

                SqlCommand deleteStateCommand = new SqlCommand(deleteStateFormat, sqlConnection);

                deleteStateCommand.ExecuteNonQuery();

                sqlConnection.Close();

                sqlConnection.Open();

                SqlCommand deleteMoneyCommand = new SqlCommand(deleteMoneyFormat, sqlConnection);

                deleteMoneyCommand.ExecuteNonQuery();

                sqlConnection.Close();
            }
        }
Exemplo n.º 2
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            Sure_Form sure_Form = new Sure_Form();

            if (sure_Form.ShowDialog() == DialogResult.Yes)
            {
                string        queryString   = "DELETE FROM dbo.Workers WHERE lastName = N'{0}'";
                SqlConnection sqlConnection = new SqlConnection(connectionString);

                sqlConnection.Open();

                string deleteFormat = string.Format(queryString, SearchTextBox.Text);

                SqlCommand sqlCommand = new SqlCommand(deleteFormat, sqlConnection);

                sqlCommand.ExecuteNonQuery();

                sqlConnection.Close();
            }
        }
Exemplo n.º 3
0
        private void DeletePS_Button_Click(object sender, EventArgs e)
        {
            Sure_Form sure_Form = new Sure_Form();

            if (sure_Form.ShowDialog() == DialogResult.Yes)
            {
                string deleteString = "DELETE FROM dbo.state_of_PS WHERE PS = N'{0}'";

                SqlConnection sqlConnection = new SqlConnection(connectionString);

                string deleteFormat = string.Format(deleteString, PS_ComboBox.Text);

                sqlConnection.Open();

                SqlCommand sqlCommand = new SqlCommand(deleteFormat, sqlConnection);

                sqlCommand.ExecuteNonQuery();

                sqlConnection.Close();
            }
        }