private string GetRecepit() { List <string> trans = new List <string>(); string orderID = GuGuGuHelper.GetOrderID(); string customerID = GuGuGuHelper.ExecuteScalar("select CustomerID from Customers").ToString(); string sql = "insert into Orders values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')"; sql = string.Format(sql, orderID, customerID, this.employeeID, GuGuGuHelper.GetNowTime(), 0, sum, "--", "--"); trans.Add(sql); for (int i = 0; GuGuGuHelper.IsInDataGridView(i, DGVStock); ++i) { { sql = string.Format("insert into \"Order Details\" values('{0}','{1}','{2}','{3}','{4}')", orderID, DGVStock.Rows[i].Cells["商品号"].Value.ToString(), DGVStock.Rows[i].Cells["单价"].Value.ToString(), DGVStock.Rows[i].Cells["数量"].Value.ToString(), DGVStock.Rows[i].Cells["折扣"].Value.ToString()); trans.Add(sql); } { sql = string.Format("update Inventory set Quantity = Quantity - '{0}' where ProductID = '{1}'", DGVStock.Rows[i].Cells["数量"].Value.ToString(), DGVStock.Rows[i].Cells["商品号"].Value.ToString()); trans.Add(sql); } } int cnt = GuGuGuHelper.ExecuteNonQueryTransaction(trans); if (cnt > 0) { MessageBox.Show("支付成功!正在打印凭条!"); } else { MessageBox.Show("出现错误!"); } DataRow rowPay = table.NewRow(); rowPay["商品名"] = "总金额"; rowPay["单价"] = LbSum.Text.Trim(); table.Rows.Add(rowPay); DataRow row = table.NewRow(); row["商品名"] = "单号"; row["单价"] = orderID; table.Rows.Add(row); DGVStock.DataSource = table; LbSum.Text = "0"; return(orderID); }