/*******************************************************************************************************/ #region DATABASE METHODS public Guid?submitNew() { //submit new sale record SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, false, true, false, false, false, "salereturn_new", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, time_stamp), new SqlQueryParameter(COL_DB_Users_Id, SqlDbType.UniqueIdentifier, user_id), new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes)) ); if (!result.IsSuccessful) { return(null); } else { ActivityLog.submitCreate(id); barcode = Tools.getHex(result.ValueInt, Settings.saleBarcodeLength); } //mark sale items as returned foreach (DataRow row in saleReturnItems.Rows) { result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "saleitem_return", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, Util.wrapNullable <Guid>(row, SaleItem.COL_ID)), new SqlQueryParameter("return_id", SqlDbType.UniqueIdentifier, id) ); if (!result.IsSuccessful) { return(null); } else { ActivityLog.submit((Guid)row[SaleItem.COL_ID], "Sale Item returned in sale return ID: " + id.ToString()); ActivityLog.submit((Guid)row[SaleItem.COL_INVENTORY_ITEM_ID], "Returned in sale return ID: " + barcode); } } return(id); }