Aizaz Ahsan

Aizaz Ahsan

  • 2k
  • 2
  • 75

Selecting list view item to edit the info inside a SQL database

Jun 10 2021 8:34 PM

Hi, first time here on this platform. Anyway, I am working on a c# project at school, where you create a database in SQL and work on that database to create an application for a restaurant. All the code is kept in separate layers. I created a windows form in the UI layer and I want to select a row. After selecting a row, I wanna edit the information in the row but not all columns at once. 

How can I make it possible to select a row item and then edit it?  Thanks in advance.


DAL Layer: 

public List<Item> Get_All_Items_DB()
            String query = "select itemID, [name], price, stock, category, Course, VATRate from ITEMS";
            SqlParameter[] parameters = new SqlParameter[0];

            return ReadItems(ExecuteSelectQuery(query, parameters));

DAO Layer:

ItemDAL itemDAO = new ItemDAL();
        public List<Item> GetItems()
            return itemDAO.Get_All_Items_DB();

UI code: 

 private void GetItemList()
            itemService = new Item_Service();
            List<Item> menuItems = itemService.GetItems();

            foreach (Item i in menuItems)
                lvItem = new ListViewItem(i.ItemID.ToString(), 0);


private void butDisplay_Click(object sender, EventArgs e)

Attachment: Screenshot_(98).zip

Answers (1)