public int SaveCheckBill(CheckListBill bill) { string commandText = GetCommandText(bill, CheckListBill.TableName, out List <OleDbParameter> sqlParameters); int result = DBConvertHelper.ExecuteNonQuery(CommandType.Text, commandText, sqlParameters.ToArray()); if (result > 0) { string strSql = "select Max(id) from " + CheckListBill.TableName; object objId = DBConvertHelper.ExecuteScalar(CommandType.Text, strSql); int.TryParse(objId.ToString(), out int id); foreach (DataRow row in bill.BillDetail.Rows) { CheckListDetail detail = CommonHelper.SetModelByDataRow <CheckListDetail>(row); detail.Id = -1; detail.Bill_id = id; commandText = GetCommandText(detail, CheckListDetail.TableName, out List <OleDbParameter> parameters); int count = DBConvertHelper.ExecuteNonQuery(CommandType.Text, commandText, parameters.ToArray()); if (count > 0) { Goods stock = new Goods { Id = detail.Goods_id, Quantity = detail.Quantity }; commandText = GetCommandText(stock, Goods.TableName, out List <OleDbParameter> paras, "Quantity"); DBConvertHelper.ExecuteNonQuery(CommandType.Text, commandText, paras.ToArray()); } result += count; } } return(result); }
public DlgCheckBillEdit(DataRow row) : this() { this.row = row; checkListBill = CommonHelper.SetModelByDataRow <CheckListBill>(row); }