想了好久还是没办法解决,你有好的办法吗?
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{//更新记录
//
//DataRow[] orw;
//DataRow dr;
//if (dsOperation.Operation.Rows.Count > 1)
//{
// orw = dsOperation.Operation.Select("IdGoodsData=\'" +cmBox.SelectedValue.ToString().Trim()+"\'");
// dsOperation.Operation.Select("IdGoodsData = \'\'");
// operationDataGridView.CancelEdit();
// if (orw != null)
// {
// dr = orw[0];
// dr["Total"] = Convert.ToDecimal(dr["Total"]) + 1;
// }
// else
// {
kcDataSet4.GoodsDataRow dr2 = kcDataSet4.GoodsData.FindByIdGoodsData(cmBox.SelectedValue.ToString());
operationDataGridView.CurrentRow.Cells["dgTxUnit"].Value = dr2.Unit.ToString();
operationDataGridView.CurrentRow.Cells["dgTxUnitPrice"].Value = Convert.ToDecimal(dr2.UnitPrice.ToString());
operationDataGridView.CurrentRow.Cells["dgTxTotal"].Value = 1;
operationDataGridView.CurrentRow.Cells["dgTxMoney"].Value = Convert.ToDecimal(dr2.Money.ToString());
operationDataGridView.CurrentRow.Cells["dgTxStandard"].Value = dr2.Standard.ToString();
if (orderIDTextBox.Text != "")
operationDataGridView.CurrentRow.Cells["dgTxOrderID"].Value = orderIDTextBox.Text.Trim();
// }
//}
//else
//{
// kcDataSet4.GoodsDataRow dr2 = kcDataSet4.GoodsData.FindByIdGoodsData(cmBox.SelectedValue.ToString());
// operationDataGridView.CurrentRow.Cells["dgTxUnit"].Value = dr2.Unit.ToString();
// operationDataGridView.CurrentRow.Cells["dgTxUnitPrice"].Value = Convert.ToDecimal(dr2.UnitPrice.ToString());
// operationDataGridView.CurrentRow.Cells["dgTxTotal"].Value = 1;
// operationDataGridView.CurrentRow.Cells["dgTxMoney"].Value = Convert.ToDecimal(dr2.Money.ToString());
// operationDataGridView.CurrentRow.Cells["dgTxStandard"].Value = dr2.Standard.ToString();
// if (orderIDTextBox.Text != "")
// operationDataGridView.CurrentRow.Cells["dgTxOrderID"].Value = orderIDTextBox.Text.Trim();
//}
}
private void operationDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (operationDataGridView.CurrentCell.ColumnIndex == 2 || operationDataGridView.CurrentCell.ColumnIndex == 3)
{
if (operationDataGridView.CurrentRow.Cells["dgTxUnitPrice"].Value.ToString() != "" && operationDataGridView.CurrentRow.Cells["dgTxTotal"].Value.ToString() != "")
{
this.Validate();
this.operationBindingSource.EndEdit();
operationDataGridView.CurrentRow.Cells["dgTxMoney"].Value = Convert.ToDecimal(operationDataGridView.CurrentRow.Cells["dgTxUnitPrice"].Value) * Convert.ToDecimal(operationDataGridView.CurrentRow.Cells["dgTxTotal"].Value);
}
}
}
当添加一个产品时,如产品成在那么就把相应的产品数量+1,否则添加,现在是怎样实现加1?
问题点数:10、回复次数:2Top
1 楼yurow(路漫漫其修远兮,吾将上下而爬楼梯!)回复于 2006-05-05 00:14:38 得分 2
用存储过程很容易,还可以减少很多CS代码Top
2 楼san12655874(小三33)回复于 2006-05-05 00:19:23 得分 8
三层架构的思想不到位。
加重了前台的负荷
可以在SQL里面写存储过程就好了,或者把思路理清楚在重新写一遍Top




