Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone help me with this question? I am having trouble.. Thanks! Solution us

ID: 2381420 • Letter: C

Question

Can anyone help me with this question?  I am having trouble..


Thanks!

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(); } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote