Omer Butt
Active member
- Joined
- Sep 6, 2021
- Messages
- 29
- Programming Experience
- Beginner
Hello to everyone,
Please Read Carefully and Answer afterwards.
Here I have an issue with C# WinForms ListBox, ListBox not showing the Same name Medicine with different details.
The Products are added to the database successfully. In which I have two medicines with the same name but are with different details,
Lets say Medicine 1 Name: Disprin = Rs.20 & Medicine 2 Name: Disprin = Rs. 50 and there are also other medicines with different names and data
The ListBox is fetching all the medicines successfully but,
Upon adding Medicines to the ListBox. In the list it is not showing the Medicine 2 with medicine 2 details but it is only showing the medicine 1 as Medicine 2 and all other Medicines with different names are fetched correctly.
Below is a code to add Medicines in ListBox:
This Query is Selecting the Names of the Medicines are neither Expired nor will Expire in 30 days Means it will add only Valid Medicines and also which are having Stock Quantity > 0.
Please instead answer theoretically try to answer practically with the code. Thanks
Above Image is showing Two Medicines with different ID and Batch no and different price but have Same name.
Above two Images showing the Issue I defined above.
Please Read Carefully and Answer afterwards.
Here I have an issue with C# WinForms ListBox, ListBox not showing the Same name Medicine with different details.
The Products are added to the database successfully. In which I have two medicines with the same name but are with different details,
Lets say Medicine 1 Name: Disprin = Rs.20 & Medicine 2 Name: Disprin = Rs. 50 and there are also other medicines with different names and data
The ListBox is fetching all the medicines successfully but,
Upon adding Medicines to the ListBox. In the list it is not showing the Medicine 2 with medicine 2 details but it is only showing the medicine 1 as Medicine 2 and all other Medicines with different names are fetched correctly.
Below is a code to add Medicines in ListBox:
Code adding Medicines in the ListBox:
private void P_SellMedicinesUC_Load(object sender, EventArgs e)
{
ListBoxMedicines.Items.Clear();
string Query = "select Med_Name from Pharmacist_Medicine where E_Date >= getdate() AND E_Date > getdate()+30 AND Stock_Quantity > '0'";
SqlDataAdapter ListMed = new SqlDataAdapter(Query, Conn.Connect);
DataTable MedList = new DataTable();
ListMed.Fill(MedList);
for (int i = 0; i < MedList.Rows.Count; i++)
{
ListBoxMedicines.Items.Add(MedList.Rows[i][0].ToString());
}
}
This Query is Selecting the Names of the Medicines are neither Expired nor will Expire in 30 days Means it will add only Valid Medicines and also which are having Stock Quantity > 0.
Please instead answer theoretically try to answer practically with the code. Thanks
Above Image is showing Two Medicines with different ID and Batch no and different price but have Same name.
Above two Images showing the Issue I defined above.
Last edited: