以下两行代码中出现以下错误:
SqlCommand cmd3 = new SqlCommand("insert into CUSTOMERINVOICE(INVOICEDATE,INVOICESTATUS,ISDEBTORINVOICE,ISLAYBYEINVOICE,INVOICETYPE,INVOICETOTAL,salesrep,dayended)" + "values(GETDATE(),0,0,0,1,'" + Convert.ToDecimal(lblTotalAmount.Text.ToString()) + "','" + txtSalesRep.Text + "',0)", conn);
cmd3.ExecuteNonQuery();
SqlDataAdapter ada2 = new SqlDataAdapter("SELECT TOP 1 ID FROM CUSTOMERINVOICE ORDER BY ID DESC", conn);
DataTable dt2 = new DataTable();
ada2.Fill(dt2);
DataRow dr2 = dt2.Rows[0];
CUSTID = Int32.Parse(dr2["ID"].ToString());
foreach (DataGridViewRow row in dgSaleBasket.Rows)
{
SqlDataAdapter ada5 = new SqlDataAdapter("SELECT itemcode,onhand,costincl FROM stmast where itemcode ='" + row.Cells[1].Value + "'", conn);
DataTable dt5 = new DataTable();
ada5.Fill(dt5);
int quantityPurchased = Int32.Parse(row.Cells[4].Value.ToString());
for (int i = 0; i < dt5.Rows.Count; i++)
{
DataRow dr5 = dt5.Rows[i];
double SellPrice = Convert.ToDouble(row.Cells[5].Value.ToString());
costinc = Convert.ToDouble(dr5["costincl"].ToString());
profit = (SellPrice - costinc) * quantityPurchased;
totalprofit = profit + totalprofit;
SqlCommand cmd4 = new SqlCommand("insert into CUSTOMERINVOICEDETAIL(INVOICEID,ITEMCODE,DESCRIPTION,QUANTITY,PRICE,profit,refund)" + "values(" + CUSTID + ",'" + row.Cells[1].Value.ToString() + "','" + row.Cells[2].Value.ToString() + "'," + row.Cells[4].Value.ToString() + ",'" + Convert.ToDecimal(row.Cells[5].Value.ToString()) + "'," + profit + ",0)", conn);
cmd4.ExecuteNonQuery();
SqlCommand cmd6 = new SqlCommand("UPDATE stmast SET onhand =onhand-" +quantityPurchased + ", lastSold =GETDATE() , lastSoldPrice=" + Convert.ToDecimal(row.Cells[5].Value.ToString()) + ",totalQtySold=totalQtySold+" + quantityPurchased + " WHERE itemcode ='" + row.Cells[1].Value + "'", conn);
cmd6.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand("UPDATE customerinvoice set invoiceprofit=" + totalprofit + " WHERE id =" + CUSTID, conn);
cmd2.ExecuteNonQuery();
}
我的代码:
TypeError: float() argument must be a string or a number, not 'Dimension'