السلام عليكم رحمة الله تعالى وبركاته
يا جماعة أحاول أن أجلب أقل قيمة سعر للمنتج في نافذة المشتريات ، ولكن الذي يحصل انني أستطيع جلب المنتج الاول في الحقل الاول للداتا ثم يرفض الاستعلام جلب حقول اخرى للداتا والصور اعتقد تبين المشكل .
الكود الذي أستعمله :
يا جماعة أحاول أن أجلب أقل قيمة سعر للمنتج في نافذة المشتريات ، ولكن الذي يحصل انني أستطيع جلب المنتج الاول في الحقل الاول للداتا ثم يرفض الاستعلام جلب حقول اخرى للداتا والصور اعتقد تبين المشكل .
الكود الذي أستعمله :
كود :
DataTable tblPrice = new DataTable();
tblPrice.Clear();
int countQty = 0;
try
{
countQty = Convert.ToInt32(db.ReadData("select sum (Pro_ID) from Products_Qty where Pro_ID = " + Cbxithem.SelectedValue + "", "").Rows[0][0]);
}
catch (Exception) { }
tblPrice = db.ReadData("select * from Products_Qty where Pro_ID = " + Cbxithem.SelectedValue + "", "");
string Product_Price = tblPrice.Rows[countQty - 1][4].ToString();
DgvBuy.Rows.Add(1);
int rowindex = DgvBuy.Rows.Count - 1;
tblunit = db.ReadData("select * from Products_Unit where Pro_ID = " + DgvBuy.CurrentRow.Cells[0].Value + " and Unit_Name = N'" + DgvBuy.CurrentRow.Cells[2].Value + "'", "");
decimal realPrice = 0;
try
{
realPrice = Convert.ToDecimal(Product_Price) / Convert.ToDecimal(tblunit.Rows[0][3]);
}
catch (Exception) { }
decimal total = Convert.ToDecimal(Product_Qty) * Convert.ToDecimal(realPrice);
DgvBuy.Rows[rowindex].Cells[4].Value = Math.Round(realPrice, 2);