【发布时间】:2016-06-18 23:34:38
【问题描述】:
在我的按钮单击代码中,如下所示,如果行值“数量”具有相同的 id,我想将其增加一,否则,开始一个新行。我该怎么做?
private void BProduct_Click(object sender, EventArgs e)
{
spGridRowClick.Visibility = Visibility.Hidden;
decimal Quantity;
decimal.TryParse(txtKeyPad.Text, out Quantity);
if (Quantity <= 1) Quantity = 1;
Button bt = (Button)sender;
productId =(int)bt.Tag;
BOneRestEntities db = new BOneRestEntities();
var results = from inv in db.Inventory
where inv.RecId == productId
select new
{
ProductId = inv.RecId,
inventoryName = inv.InventoryName,
Quantity,
Total = Quantity * inv.InventoryPrice
};
foreach (var x in results)
{
DataRow newRow = dt.NewRow();
newRow.SetField("inventoryName", x.inventoryName);
newRow.SetField("Quantity", x.Quantity);
newRow.SetField("Total", x.Total);
newRow.SetField("ProductId", x.ProductId);
dt.Rows.Add(newRow);
}
txtKeyPad.Clear();
gridCalculate.ItemsSource = dt;
gridCalculate.View.MoveNextRow();
TotalRow();
}
【问题讨论】:
标签: c# devexpress-wpf