منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : جلب أقل قيمة سعر من جدول الى الداتاغريد
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم رحمة الله تعالى وبركاته


يا جماعة أحاول أن أجلب أقل قيمة سعر للمنتج في نافذة المشتريات ، ولكن الذي يحصل انني أستطيع جلب المنتج الاول في الحقل الاول للداتا ثم يرفض الاستعلام جلب حقول اخرى للداتا والصور اعتقد تبين المشكل .

الكود الذي أستعمله : 


كود :
  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);




[صورة مرفقة: attachment.php?aid=22813]

[صورة مرفقة: attachment.php?aid=22814]
هذا استعلام اقل قيمة :

PHP كود :
Select Pro_ID,Store_ID,Store_Name,Qty,Min(Buy_Price)As Buy_Price,Sales_PriceTax From Products_Qty 
(03-09-19, 02:59 AM)asemshahen5 كتب : [ -> ]هذا استعلام اقل قيمة :

PHP كود :
Select Pro_ID,Store_ID,Store_Name,Qty,Min(Buy_Price)As Buy_Price,Sales_PriceTax From Products_Qty 

الله يحفظك و ينور طريقك ويعطيك ما تتمناه وتريده
(03-09-19, 11:43 PM)tfarejdz كتب : [ -> ]
(03-09-19, 02:59 AM)asemshahen5 كتب : [ -> ]هذا استعلام اقل قيمة :

PHP كود :
Select Pro_ID,Store_ID,Store_Name,Qty,Min(Buy_Price)As Buy_Price,Sales_PriceTax From Products_Qty 

الله يحفظك و ينور طريقك ويعطيك ما تتمناه وتريده

تم التعديل مع بعض التعديلات والنتائج تظهر ممتازة على الغريدفيو


PHP كود :
int countQty 0;
 
                   try
                    
{
 
                       countQty Convert.ToInt32(db.ReadData("select sum(Pro_ID)As Pro_ID from Products_Qty where Pro_ID = " Cbxithem.SelectedValue " GROUP BY Pro_ID""").Rows[0][0]);
 
                   }
 
                   catch (Exception) { }


 
                   tblPrice db.ReadData("Select Pro_ID,Store_ID,Store_Name,Qty,Min(Buy_Price)As Buy_Price,Sales_PriceTax From Products_Qty where Pro_ID = " Cbxithem.SelectedValue " GROUP BY Pro_ID , Store_ID , Store_Name , Qty , Buy_Price , Sales_PriceTax """);


string Product_ID tblItems.Rows[0][0].ToString();
 
                   string Product_Name tblItems.Rows[0][1].ToString();
 
                   string Product_Qty "1";
 
                   string Product_Price tblPrice.Rows[indexcountQty 0][4].ToString();
 
                   string Product_Unit tblItems.Rows[0][16].ToString();
 
                   decimal Discount 0;


 
                   DgvBuy.Rows.Add(1);
 
                   int rowindex DgvBuy.Rows.Count 1;

 
                   DgvBuy.Rows[rowindex].Cells[0].Value Product_ID;
 
                   DgvBuy.Rows[rowindex].Cells[1].Value Product_Name;
 
                   DgvBuy.Rows[rowindex].Cells[2].Value Product_Unit;
 
                   DgvBuy.Rows[rowindex].Cells[3].Value Product_Qty;
 
                   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(realPrice2);
 
                   DgvBuy.Rows[rowindex].Cells[5].Value Discount;
 
                   DgvBuy.Rows[rowindex].Cells[6].Value Math.Round(total2);
 
               }
 
               catch (Exception) { } 



شكرا جزيلا على المساعدة
الحمد الله و الشكر الله .