04-09-19, 02:02 AM
(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[index: countQty = 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(realPrice, 2);
DgvBuy.Rows[rowindex].Cells[5].Value = Discount;
DgvBuy.Rows[rowindex].Cells[6].Value = Math.Round(total, 2);
}
catch (Exception) { }
شكرا جزيلا على المساعدة
