S
Smok blackmossiba
Guest
Hello, i have some problems and i hope somebody can help me please.
when i insert a new product with the same Id, i need the price just to be refreshed not add a new row, and if it is not i need a new row
DaL.Open();
SqlCommand cmd = new SqlCommand("Select*from Produit where produit_Id=" + productsBox.SelectedValue.ToString() + "", DAL.Acesslayer.Conx);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
if (PanelGrid.Rows.Count == 0)
{
Quantity_Price = int.Parse(quantityBox.Value.ToString()) * int.Parse(dt.Rows[3].ToString());
PanelGrid.Rows.Add(dt.Rows[0], dt.Rows[1], quantityBox.Value.ToString(), Quantity_Price.ToString(), dt.Rows[5]);
}
Found = FC.SearchProduct(PanelGrid.Rows.Cells[1].Value.ToString());
MessageBox.Show(PanelGrid.Rows.Cells[1].Value.ToString());
if (Found == true)
{
PanelGrid.Rows.RemoveAt(i);
Quantity_Price = int.Parse(quantityBox.Value.ToString()) * int.Parse(dt.Rows[3].ToString());
PanelGrid.Rows.Add(dt.Rows[0], dt.Rows[1], quantityBox.Value.ToString(), Quantity_Price.ToString(), dt.Rows[5]);
}
else
{
if (Found ==false && PanelGrid.Rows.Count != 0)
{
Quantity_Price = int.Parse(quantityBox.Value.ToString()) * int.Parse(dt.Rows[3].ToString());
PanelGrid.Rows.Add(dt.Rows[0], dt.Rows[1], quantityBox.Value.ToString(), Quantity_Price.ToString(), dt.Rows[5]);
}
}
}
Continue reading...
when i insert a new product with the same Id, i need the price just to be refreshed not add a new row, and if it is not i need a new row
DaL.Open();
SqlCommand cmd = new SqlCommand("Select*from Produit where produit_Id=" + productsBox.SelectedValue.ToString() + "", DAL.Acesslayer.Conx);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
if (PanelGrid.Rows.Count == 0)
{
Quantity_Price = int.Parse(quantityBox.Value.ToString()) * int.Parse(dt.Rows[3].ToString());
PanelGrid.Rows.Add(dt.Rows[0], dt.Rows[1], quantityBox.Value.ToString(), Quantity_Price.ToString(), dt.Rows[5]);
}
Found = FC.SearchProduct(PanelGrid.Rows.Cells[1].Value.ToString());
MessageBox.Show(PanelGrid.Rows.Cells[1].Value.ToString());
if (Found == true)
{
PanelGrid.Rows.RemoveAt(i);
Quantity_Price = int.Parse(quantityBox.Value.ToString()) * int.Parse(dt.Rows[3].ToString());
PanelGrid.Rows.Add(dt.Rows[0], dt.Rows[1], quantityBox.Value.ToString(), Quantity_Price.ToString(), dt.Rows[5]);
}
else
{
if (Found ==false && PanelGrid.Rows.Count != 0)
{
Quantity_Price = int.Parse(quantityBox.Value.ToString()) * int.Parse(dt.Rows[3].ToString());
PanelGrid.Rows.Add(dt.Rows[0], dt.Rows[1], quantityBox.Value.ToString(), Quantity_Price.ToString(), dt.Rows[5]);
}
}
}
Continue reading...