Hello, This question is posted but I am having trouble with the form. I specific
ID: 3869146 • Letter: H
Question
Hello, This question is posted but I am having trouble with the form. I specifically I am having trouble creating the form. C# Write an application that displays revenue generated for exercise classes at the Tappan Gym. The gym offers two types of exercise classes, zumba and spinning, six days per week, four times per day. Zumba is offered at 1, 3, 5, and 7 p.m.; spinning is offered at 2, 4, 6, and 8 p.m. When attendees sign up, they agree to pay $4.00 per class for zumba and $5.00 for spinning. Produce a table displaying the number of attendees per time slot. Display a row and column of totals showing the total number of attendees by day and also time period. Also include a column showing the revenue generated each day and the overall revenue per type of exercise. Do a compile-time initialization of your data structures using data from the following table. Zumba 1:00 3:00 5:00 7:00 Monday 12 10 17 22 Tuesday 11 13 17 22 Wednesday 12 10 22 22 Thursday 9 14 17 22 Friday 12 10 21 12 Saturday 12 10 5 10 Spinning 2:00 4:00 6:00 8:00 Monday 7 11 15 8 Tuesday 9 9 9 9 Wednesday 3 12 13 7 Thursday 2 9 9 10 Friday 8 4 9 4 Saturday 4 5 9 3
Explanation / Answer
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication9 { public partial class Form1 : Form { SqlConnection con; SqlCommand cmd; SqlDataReader dr; string SqlStr; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { con = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=employee;Integrated Security=True"); //textBox1.Text = con.ConnectionString; con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "Select Empno,Ename,Job,Salary From Emplye Order By Empno"; dr = cmd.ExecuteReader(); ShowData(); } private void ShowData() { if (dr.Read()) { textBox1.Text = dr[0].ToString(); textBox2.Text = dr[1].ToString(); textBox3.Text = dr[2].ToString(); textBox3.Text = dr[3].ToString(); } else MessageBox.Show("No data exists."); } private void button1_Click(object sender, EventArgs e) { ShowData(); } private void button2_Click(object sender, EventArgs e) { textBox1.Text=textBox2.Text=textBox3.Text=textBox4.Text=""; dr.Close(); cmd.CommandText="select IsNULL(Max(Empno),1000)+1 From Emplye"; textBox1.Text=cmd.ExecuteScalar().ToString(); button3.Enabled = true; textBox2.Focus(); } private void ExecuteDML() { DialogResult d = MessageBox.Show("Are you sure of executing the below Sql Statement? " + SqlStr, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d == DialogResult.Yes) { cmd.CommandText = SqlStr; int count = cmd.ExecuteNonQuery(); if (count > 0) MessageBox.Show("Statement excuted successfully"); else MessageBox.Show("Statement failed execution"); ShowData(); } } private void button3_Click(object sender, EventArgs e) { SqlStr="Insert Emplye(Empno,Ename,Job,Salary)Values("+textBox1.Text+",'"+textBox2.Text+"'.'"+textBox3.Text+"',"+textBox4.Text+")"; ExecuteDML(); } private void button4_Click(object sender, EventArgs e) { SqlStr="Update Emplye Set Ename='"+textBox2.Text+"',Job='"+textBox3.Text+"',salary="+textBox4.Text+"where Empno+"+textBox1.Text;dr.Close(); ExecuteDML(); } private void button5_Click(object sender, EventArgs e) { SqlStr="Delete From Employe where Empno="+textBox1.Text; dr.Close(); ExecuteDML(); } private void button6_Click(object sender, EventArgs e) { if(con.State != ConnectionState.Closed) { con.Close(); } this.Close(); } } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.