这是存储过程exec('SELECT distinct ghy_Jxc_InventoryMx.Id AS 编号, ghy_Jxc_InventoryMx.InventoryId AS 入库单号, ghy_Jxc_GoodsSet.GoodsMc AS 商品名称, ghy_Jxc_InventoryMx.Amount AS 商品数量, ghy_Jxc_InventoryMx.ItemCount AS 中间单位数量, ghy_Jxc_InventoryMx.BoxCount AS 最小单位数量, ghy_Jxc_InventoryMx.GjDj AS 购进单价, ghy_Jxc_InventoryMx.XsDj AS 销售单价, ghy_Jxc_InventoryMx.PfDj AS 批发单价, ghy_Jxc_InventoryMx.DbDj AS 调拨单价, ghy_Jxc_InventoryMx.ZdDj AS 最低单价, ghy_Jxc_wareHouse.WhName AS 仓库名称, ghy_Jxc_InventoryMx.Whaddress AS 仓库地址, ghy_Jxc_GoodsSetType.GoodsType AS 商品类别, ghy_Jxc_GoodsSet.GoodsCd as 商品产地 FROM ghy_Jxc_InventoryMx INNER JOIN ghy_Jxc_GoodsSet ON ghy_Jxc_InventoryMx.GoodsId = ghy_Jxc_GoodsSet.GoodsId INNER JOIN ghy_Jxc_wareHouse ON ghy_Jxc_InventoryMx.WareHouseId = ghy_Jxc_wareHouse.id INNER JOIN ghy_Jxc_GoodsSetType ON ghy_Jxc_GoodsSet.GoodsType = ghy_Jxc_GoodsSetType.Id CROSS JOIN ghy_Jxc_Gg '+@Whe+'')
if (this.dataGridView1.SelectedRows.Count == 1)
{
//string ss = this.dataGridView1.CurrentRow.Cells[0].vToString();
sdr = add.sGetInventoryMxToEnterDat("where ghy_Jxc_InventoryMx.Id=" + this.dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString());
if (sdr.Read())
{
this.cmbGoodsName.Text = sdr["商品名称"].ToString();
this.txtGoodsLb.Text = sdr["商品类别"].ToString();
this.txtGoodsCd.Text = sdr["商品产地"].ToString();
// MessageBox.Show(sdr["商品数量"].ToString() + " ");
this.txtSl.Text = sdr["商品数量"].ToString();
this.txtMidCount.Text = sdr["中间单位数量"].ToString(); this.txtSmalCount.Text = sdr["最小单位数量"].ToString();
this.txtGjDj.Text = sdr["购进单价"].ToString();
this.txtDbDj.Text = sdr["调拨单价"].ToString();
this.txtPfDj.Text = sdr["批发单价"].ToString();
this.cmbCk.Text = sdr["仓库名称"].ToString();
this.txtCw.Text = sdr["仓库地址"].ToString();
} }把商品数量,中间单位数量,最小单位数量注释上后就正确了,我真是迷糊,是因为数量是int型
我想这也不可能有影响啊!
ghy_Jxc_InventoryMx.Amount AS 商品数量, ghy_Jxc_InventoryMx.ItemCount AS 中间单位数量, ghy_Jxc_InventoryMx.BoxCount AS 最小单位数量,
ghy_Jxc_InventoryMx.GjDj AS 购进单价, ghy_Jxc_InventoryMx.XsDj AS 销售单价, ghy_Jxc_InventoryMx.PfDj AS 批发单价,
ghy_Jxc_InventoryMx.DbDj AS 调拨单价, ghy_Jxc_InventoryMx.ZdDj AS 最低单价, ghy_Jxc_wareHouse.WhName AS 仓库名称,
ghy_Jxc_InventoryMx.Whaddress AS 仓库地址, ghy_Jxc_GoodsSetType.GoodsType AS 商品类别, ghy_Jxc_GoodsSet.GoodsCd as 商品产地
FROM ghy_Jxc_InventoryMx INNER JOIN
ghy_Jxc_GoodsSet ON ghy_Jxc_InventoryMx.GoodsId = ghy_Jxc_GoodsSet.GoodsId INNER JOIN
ghy_Jxc_wareHouse ON ghy_Jxc_InventoryMx.WareHouseId = ghy_Jxc_wareHouse.id INNER JOIN
ghy_Jxc_GoodsSetType ON ghy_Jxc_GoodsSet.GoodsType = ghy_Jxc_GoodsSetType.Id CROSS JOIN
ghy_Jxc_Gg '+@Whe+'')
this.dataGridView1.Rows.Count是几?
这个this.dataGridView1.Rows[]可是从0开始的!
{
if (this.dataGridView1.SelectedRows.Count == 1)
{
//string ss = this.dataGridView1.CurrentRow.Cells[0].vToString();
sdr = add.sGetInventoryMxToEnterDat("where ghy_Jxc_InventoryMx.Id=" + this.dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString());
if (sdr.Read())
{
this.cmbGoodsName.Text = sdr["商品名称"].ToString();
this.txtGoodsLb.Text = sdr["商品类别"].ToString();
this.txtGoodsCd.Text = sdr["商品产地"].ToString();
// MessageBox.Show(sdr["商品数量"].ToString() + " ");
this.txtSl.Text = sdr["商品数量"].ToString();
this.txtMidCount.Text = sdr["中间单位数量"].ToString(); this.txtSmalCount.Text = sdr["最小单位数量"].ToString();
this.txtGjDj.Text = sdr["购进单价"].ToString();
this.txtDbDj.Text = sdr["调拨单价"].ToString();
this.txtPfDj.Text = sdr["批发单价"].ToString();
this.cmbCk.Text = sdr["仓库名称"].ToString();
this.txtCw.Text = sdr["仓库地址"].ToString();
} }
}
this.txtGoodsLb.Text = sdr["商品类别"].ToString();
this.txtGoodsCd.Text = sdr["商品产地"].ToString();
也应该是错误的啊!
把
sdr = add.sGetInventoryMxToEnterDat("where ghy_Jxc_InventoryMx.Id=" + this.dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString());
改成
sdr = add.sGetInventoryMxToEnterDat("where ghy_Jxc_InventoryMx.Id=" + this.dataGridView1.SelectedRows[0].Cells["编号"].Value.ToString());
试试?
还有在debug中运行exe时报错后单击继续,下一次又好使了,然后又不好使,在下一次又好使!
this.cmbGoodsName.Text = sdr["商品名称"].ToString();
执行的时候就该报错了把!
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
if (this.dataGridView1.SelectedRows.Count == 1)
{
//string ss = this.dataGridView1.CurrentRow.Cells[0].vToString();
sdr = add.sGetInventoryMxToEnterDat("where ghy_Jxc_InventoryMx.Id=" + this.dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString());
if (sdr.Read())
{
this.txtSl.Text = sdr["商品数量"].ToString();
this.txtMidCount.Text = sdr["中间单位数量"].ToString(); this.txtSmalCount.Text = sdr["最小单位数量"].ToString();
this.cmbGoodsName.Text = sdr["商品名称"].ToString();
this.txtGoodsLb.Text = sdr["商品类别"].ToString();
this.txtGoodsCd.Text = sdr["商品产地"].ToString();
// MessageBox.Show(sdr["商品数量"].ToString() + " ");
this.txtGjDj.Text = sdr["购进单价"].ToString();
this.txtDbDj.Text = sdr["调拨单价"].ToString();
this.txtPfDj.Text = sdr["批发单价"].ToString();
this.cmbCk.Text = sdr["仓库名称"].ToString();
this.txtCw.Text = sdr["仓库地址"].ToString();
} }
}
将数量的移动到上就好使了 ,这是为什么呢?
还有人碰到这种现象吗?
有知道原因的吗?