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

You are to create a C# Windows Forms (GUI) application that conforms to the foll

ID: 3725685 • Letter: Y

Question

You are to create a C# Windows Forms (GUI) application that conforms to the following specifications:

1. Load a list box with information about library patrons. The each list box item should contain a patron ID and a patron name. You will read information from the patron table of the database and use the information that you have retrieved from the database to load the list box.


2. Each time an item is selected in the patron list box, do the following:
a. Retrieve all of the rows in the borrower table that are associated with the patronID of the item that was selected in the patron list box.
b. Use the data retrieved from the borrow table (as described in the bullet above), and populate a list box with the following information:
i. Book title
ii. Book due date

Current Code I have

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

namespace Homework5

{

    class Program

    {

        static string connectionString;

        static SqlConnection connection;

        static SqlDataAdapter adapter;

        static void Main(string[] args)

        {

            InitializeDatabaseObjects();

            CloseDatabase();

        }

        static void InitializeDatabaseObjects()

        {

            connectionString = ConfigurationManager.ConnectionStrings["Homework5.Properties.Settings.libraryConnectionString"].ConnectionString;

            connection = new SqlConnection(connectionString);

            connection.Open();

        }

        static void QueryPatronData()

        {

            string query = "SELECT * from Patron";

            DataTable patronTable;

            patronTable = new DataTable()

            adapter = new SqlDataAdapter(query, connection);

            adapter.Fill(patronTable);

        }

        static void CloseDatabase()

        {

            connection.Close();

        }

     }

Server Explorer l Azure lections.Generic; Data Connections library.mdf Tables eading.Tasks; Dborrow EE patron a.SqlClient; figuration; DViews DStored Procedures Functions DSynonyms Types Assemblies tring connectionString; q1Connection connection; qlDataAdapter adapter; Servers SharePoint Connections void Main(stringt] args) ializeDatabaseObjects); eDatabase 2 Errors | 1 warning | | 0 0 Me ion Program.adapter' is never used Ready

Explanation / Answer

/// Please edit code and used your dbconnection......

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Homework5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
using (SqlConnection connection = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|DatabaseName.mdf;Integrated Security=True;User Instance=True"))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(
"select * from TableName", connection);
adapter.Fill(ds, "cheggAuth");
}
LoadList(ds);

}

private void LoadList(DataSet ds)
{
// Get the table from the data set
DataTable dtable = ds.Tables["cheggAuth"];


listView1.Items.Clear();
// Display items in the ListView control
for (int i = 0; i < dtable.Rows.Count; i++)
{

DataRow drow = dtable.Rows[i];

// Define the list items
  
ListViewItem lvi = new ListViewItem(drow["patronID "].ToString());
lvi.SubItems.Add(drow["patronName"].ToString());

// Add the list items to the ListView
listView1.Items.Add(lvi);
}
}

private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{

}
}
}

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