Click here to Skip to main content
15,922,155 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi
i need a help , how to show/enter a purchase stock item and show the item description in datagridview after selecting the item.

my win form datagridview is desgined dynamically and using sql statement.

thanks in advance.

additional information copied from comment below - Nelek

My Question is i have stock item table {item no, item name } and purchase child table include { item no}, i want to have datagridview have item no from purchase child and when select item it show the item name directly. have a relation between parent and child.

i used this code but i am not convinced ;

C#
private string selectQueryStringPurChild = "SELECT dbo.acc_PurChild.iRecnoPur, dbo.acc_PurChild.iPurchaseID, dbo.acc_PurChild.iStockID, " +
"dbo.acc_Stkitem.cFullname, dbo.acc_PurChild.nQty, dbo.acc_PurChild.nDisc, dbo.acc_PurChild.nCost, " +
"dbo.acc_PurChild.nTotal, dbo.acc_PurChild.nVat, dbo.acc_PurChild.nLine " +
"FROM         dbo.acc_PurChild INNER JOIN " +
"dbo.acc_Stkitem ON dbo.acc_PurChild.iStockID = dbo.acc_Stkitem.iStockID";

private void dgvacc_PurChild_CellLeave(object sender, DataGridViewCellEventArgs e)
{
  int ncolumn = dgvacc_PurChild.CurrentCell.ColumnIndex;
  switch (ncolumn)
  {
    case 1:
      GetStockItemFullName();
      break;
  }
}

private void GetStockItemFullName()
{
  dgvacc_PurChild.CurrentRow.Cells[2].Value = "2222";
}
Posted
Updated 1-Jun-13 9:56am
v2
Comments
CHill60 1-Jun-13 14:06pm    
You will need to use the Improve question link to add detail to this question to get any sensible answers. We cannot see your screen or code to even attempt to work out what you are actually trying to do or where your problem is
ahmad zrein 1-Jun-13 14:21pm    
My Question is i have stock item table {item no, item name } and purchase child table include { item no}, i want to have datagridview have item no from purchase child and when select item it show the item name directly. have a relation between parent and child.

i used this code but i am not convinced ;

private string selectQueryStringPurChild = "SELECT dbo.acc_PurChild.iRecnoPur, dbo.acc_PurChild.iPurchaseID, dbo.acc_PurChild.iStockID, " +
"dbo.acc_Stkitem.cFullname, dbo.acc_PurChild.nQty, dbo.acc_PurChild.nDisc, dbo.acc_PurChild.nCost, " +
"dbo.acc_PurChild.nTotal, dbo.acc_PurChild.nVat, dbo.acc_PurChild.nLine " +
"FROM dbo.acc_PurChild INNER JOIN " +
"dbo.acc_Stkitem ON dbo.acc_PurChild.iStockID = dbo.acc_Stkitem.iStockID";

private void dgvacc_PurChild_CellLeave(object sender, DataGridViewCellEventArgs e)
{
int ncolumn = dgvacc_PurChild.CurrentCell.ColumnIndex;
switch (ncolumn)
{
case 1:
GetStockItemFullName();
break;
}
}

private void GetStockItemFullName()
{
dgvacc_PurChild.CurrentRow.Cells[2].Value = "2222";
}
Swayam231 1-Jun-13 14:44pm    
don't write code in comments..
use improve question link and paste the code there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900