csharpnoob
Member
- Joined
- Dec 22, 2022
- Messages
- 11
- Programming Experience
- Beginner
hi
so my problem when i add new items its ok but when add another one its take first one price ..
here ss
so my problem when i add new items its ok but when add another one its take first one price ..
here ss
C#:
if (tblProduct.Rows.Count >= 1)
{
try
{
string Pro_id = tblProduct.Rows[0][0].ToString();
string Pro_Name = tblProduct.Rows[0][1].ToString();
string Product_Qty = "1";
decimal Product_discount = 0;
string units_pro = tblProduct.Rows[0][14].ToString();
dgvbuy.Rows.Add(1);
int rowindex = dgvbuy.Rows.Count - 1;
dgvbuy.Rows[rowindex].Cells[0].Value = Pro_id;
dgvbuy.Rows[rowindex].Cells[1].Value = Pro_Name;
dgvbuy.Rows[rowindex].Cells[3].Value = Product_Qty;
dgvbuy.Rows[rowindex].Cells[2].Value = units_pro;
tblUnit = db.readData("select * from Products_Units where Pro_ID=" + dgvbuy.CurrentRow.Cells[0].Value + " and Unit_Name=N'" + dgvbuy.CurrentRow.Cells[2].Value + "'", ""); /////
decimal price= 0;
try
{
price= (decimal)tblUnit.Rows[0][5] / (decimal)tblUnit.Rows[0][3]; //
}
catch (Exception)
{
}
dgvbuy.Rows[rowindex].Cells[4].Value = price; // i think here the prblm but dont knew how to fix !!!
decimal total = Convert.ToDecimal(Product_Qty) * Convert.ToDecimal(price);
dgvbuy.Rows[rowindex].Cells[5].Value = Product_discount;
dgvbuy.Rows[rowindex].Cells[6].Value = total;
//dgvbuy.Rows.Add();
//dgvbuy.RefreshEdit();
}