private void insertBtn_Click(object sender, EventArgs e)
        {
            var sql = "INSERT INTO Calls (Fname, Mint, Lname, Address, Reason_for_call) " +
                      "VALUES (@firstName, @middleInt, @lastName, @address, @reason);";

            string connectionString = Emergancy_Room_Database.Properties.Settings.Default.ERDatabaseConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@firstName", fNameTB.Text);
                    cmd.Parameters.AddWithValue("@middleInt", MITB.Text);
                    cmd.Parameters.AddWithValue("@lastName", lNameTB.Text);
                    cmd.Parameters.AddWithValue("@address", addressTB.Text);
                    cmd.Parameters.AddWithValue("@reason", reasonTB.Text);
                    cmd.ExecuteNonQuery();
                }
            }
            this.Hide();
            displayCallsTable displayCallsTable = new displayCallsTable();

            displayCallsTable.ShowDialog();
            this.Close();
        }
        private void updateBtn_Click(object sender, EventArgs e)
        {
            int id  = int.Parse(IDlbl.Text);
            var sql = "UPDATE Calls SET Fname = @firstName, Mint = @middleInt, Lname = @lastName, Address = @address, Reason_for_call = @reason WHERE Call_Id = @id";

            string connectionString = Emergancy_Room_Database.Properties.Settings.Default.ERDatabaseConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@firstName", fNameTB.Text);
                    cmd.Parameters.AddWithValue("@middleInt", MITB.Text);
                    cmd.Parameters.AddWithValue("@lastName", lNameTB.Text);
                    cmd.Parameters.AddWithValue("@address", addressTB.Text);
                    cmd.Parameters.AddWithValue("@reason", reasonForCallTB.Text);
                    cmd.Parameters.AddWithValue("@id", id);
                    cmd.ExecuteNonQuery();
                }
            }
            this.Hide();
            displayCallsTable displayCallsTable = new displayCallsTable();

            displayCallsTable.ShowDialog();
            this.Close();
        }
Example #3
0
        private void displayCallsBtn_Click(object sender, EventArgs e)
        {
            this.Hide();
            displayCallsTable displayCallsTable = new displayCallsTable();

            displayCallsTable.ShowDialog();
            this.Close();
        }
Example #4
0
        private void enterBtn_Click(object sender, EventArgs e)
        {
            int id  = int.Parse(idChoiceTb.Text);
            var sql = "DELETE FROM Calls WHERE Call_Id = @id";

            string connectionString = Emergancy_Room_Database.Properties.Settings.Default.ERDatabaseConnectionString;

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new SqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@id", id);
                    cmd.ExecuteNonQuery();
                }
            }
            this.Hide();
            displayCallsTable displayCallsTable = new displayCallsTable();

            displayCallsTable.ShowDialog();
            this.Close();
        }